﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Text.RegularExpressions;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public delegate void deleTest();
        AccessRead ar = null;
        bool isbreak = false;
        public Form1()
        {
            InitializeComponent();
        }
        private void catFun()
        {
            this.simpleButton5.Text = "。。。";
            this.simpleButton5.Enabled = false;
            string strsql1 = "";
            string strsql2 = "";
            DataSet ds = null;
            DataSet dsdate = null;
            DataTable dtdateall = null;
            DataTable dt = null;
            DataTable dtall = null;
            string homeGoal = "";
            string vistorGoal = "";
            int iright = 0;
            int iall = 0;
            try
            {
                isbreak = false; ;
                memoEdit1.Text = "";
                if (checkEdit7.Checked == false)
                {
                    if (comboBoxEdit1.Text != "竞猜" && comboBoxEdit1.Text != "新竞猜")
                        dsdate = ar.ReturnDataSet("select  distinct top " + comboBoxEdit5.Text + " gameDate from fb_gamelist where guessType='" + comboBoxEdit1.Text + "' order by gameDate " + comboBoxEdit6.Text + " ");
                    else
                        dsdate = ar.ReturnDataSet("select  distinct top " + comboBoxEdit5.Text + " gameDate from fb_gamelist where guessType='" + comboBoxEdit1.Text + "' order by gameDate " + comboBoxEdit6.Text + "  ");
                }
                else
                    dsdate = ar.ReturnDataSet("select distinct gameDate from fb_gamelist where gameDate='" + comboBoxEdit2.Text + "' order by gameDate desc ");
                dtdateall = dsdate.Tables[0];
                foreach (DataRow dtdate in dtdateall.Rows)
                {
                    if (isbreak) break;
                    strsql2 = " guessNum like'%"
                           + dtdate["gameDate"] + "%'";
                    if (checkEdit7.Checked)
                    {
                        strsql2 += " and  (GameScore='' or GameScore is null )  ";
                    }
                    else
                    {
                        strsql2 += " and  1=1 ";
                    }

                    strsql1 = "select  * from  fb_gamelist where guessType='" + comboBoxEdit1.Text + "' and " + strsql2 + " ORDER BY guessNum  ";
                    dsdate = ar.ReturnDataSet(strsql1);
                    dtall = dsdate.Tables[0];
                    if (dsdate.Tables.Count == 0) continue;
                    int i = 1, j = 1;
                    double ispan = 1.1;
                    iright = 0;
                    iall = 0;
                    foreach (DataRow drall in dtall.Rows)
                    {
                        if (isbreak) break;
                        this.Text = "" + drall["guessNum"] + ":" + iright + "(" + iall + ")";
                        strsql1 = "select  * from fbOddTeamResultView where guessNum='"
                                + drall["guessNum"] + "' and instr(type,'主队')>0 and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                        ds = ar.ReturnDataSet(strsql1);
                        if (ds.Tables.Count == 0) continue;
                        DataTable dttemp = ds.Tables[0];
                        if (dttemp.Rows.Count == 0) continue;
                        Hashtable hsbqdate = new Hashtable();
                        Hashtable hsbq = new Hashtable();
                        Hashtable hsbqteam = new Hashtable();
                        Hashtable hsbqnum = new Hashtable();
                        Hashtable hsscore = new Hashtable();
                        Hashtable hsGameResult = new Hashtable();
                        Hashtable hsteam = new Hashtable();
                        Hashtable hsnum = new Hashtable();
                        Hashtable hsdate = new Hashtable();
                        double goalmax = 0, goalmin = 99999, goalvmax = 0, goalvmin = 99999, goalmarmax = 0, goalmarmin = 99999;
                        if (dttemp.Rows.Count > 0)
                        {
                            foreach (DataRow drtemp in dttemp.Rows)
                            {
                                if (isbreak) break;
                                if (drtemp["type"].ToString().IndexOf("半场") > -1) continue;
                                if (Convert.ToDouble(drtemp["goalVGame"].ToString()) > goalmax)
                                {
                                    goalmax = Convert.ToDouble(drtemp["goalVGame"].ToString());
                                }
                                if (goalmin > Convert.ToDouble(drtemp["goalVGame"].ToString()))
                                {
                                    goalmin = Convert.ToDouble(drtemp["goalVGame"].ToString());
                                }

                                if (Convert.ToDouble(drtemp["oppGoalVGame"].ToString()) > goalvmax)
                                {
                                    goalvmax = Convert.ToDouble(drtemp["oppGoalVGame"].ToString());
                                }
                                if (goalvmin > Convert.ToDouble(drtemp["oppGoalVGame"].ToString()))
                                {
                                    goalvmin = Convert.ToDouble(drtemp["oppGoalVGame"].ToString());
                                }

                                //if (drtemp["type"].ToString().IndexOf("近六轮") > -1) continue;
                                if (Convert.ToDouble(drtemp["marginGoal"].ToString()) > goalmarmax)
                                {
                                    goalmarmax = Convert.ToDouble(drtemp["marginGoal"].ToString());
                                }
                                if (goalmarmin > Convert.ToDouble(drtemp["marginGoal"].ToString()))
                                {
                                    goalmarmin = Convert.ToDouble(drtemp["marginGoal"].ToString());
                                }
                            }


                        }

                        homeGoal = dttemp.Rows[0]["homeGoal"].ToString();
                        vistorGoal = dttemp.Rows[0]["vistorGoal"].ToString();
                        string homeTeamName = dttemp.Rows[0]["homeTeamName"].ToString().Substring(dttemp.Rows[0]["homeTeamName"].ToString().IndexOf("(") + 1, dttemp.Rows[0]["homeTeamName"].ToString().IndexOf(")") - dttemp.Rows[0]["homeTeamName"].ToString().IndexOf("(") - 1).Replace(" ", "");
                        string vistortTeamName = dttemp.Rows[0]["vistortTeamName"].ToString().Substring(dttemp.Rows[0]["vistortTeamName"].ToString().IndexOf("(") + 1, dttemp.Rows[0]["vistortTeamName"].ToString().IndexOf(")") - dttemp.Rows[0]["vistortTeamName"].ToString().IndexOf("(") - 1).Replace(" ", "");
                        DateTime  dttimetemp=Convert.ToDateTime(dttemp.Rows[0]["fb_gamelist.inTime"].ToString());
                        string time = dttimetemp.ToString("yyyy-MM");
                        homeTeamName = homeTeamName.Replace(" ", "");
                        vistortTeamName = vistortTeamName.Replace(" ", "");
                        if (hsteam.ContainsKey(homeTeamName + "-" + vistortTeamName + "-" + time) == false) hsteam.Add(homeTeamName + "-" + vistortTeamName + "-" + time, 1);
                        if (hsbqteam.ContainsKey(homeTeamName + "-" + vistortTeamName + "-" + time) == false) hsbqteam.Add(homeTeamName + "-" + vistortTeamName + "-" + time, 1);
                        //strsql1 = "abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
                        //        + ")<1 and abs(oppGoalVGame-"
                        //        + dttemp.Rows[0]["oppGoalVGame"].ToString()
                        //        + ")<1 and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1   and oddCompany='" + comboBoxEdit4.Text + "' and type='主队近六轮' and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";
                        strsql1 = (goalmax + ispan) + " >=CDBL(goalVGame) and CDBL(goalVGame)>=" + (goalmin - ispan) + " and "
                           + (goalvmax + ispan) + ">=CDBL(oppGoalVGame) and CDBL(oppGoalVGame)>=" + (goalvmin - ispan)
                           + " and "
                           + (goalmarmax + ispan) + ">=CDBL(marginGoal) and CDBL(marginGoal)>=" + (goalmarmin - ispan) + "    and oddCompany='" + comboBoxEdit4.Text + "'  and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";

                        strsql2 = "   guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   )";
                        strsql1 = "select * from  fb_gamelist where  " + strsql2 + "    and intime<dateadd('h',-1, cdate('" + drall["intime"] + "')) ";
                        //strsql1 = "select * from  fb_gamelist where  " + strsql2 + "     ";
                        ds = ar.ReturnDataSet(strsql1);
                        if (ds.Tables.Count == 0) continue;
                        dttemp = ds.Tables[0];
                        if (dttemp.Rows.Count == 0) continue;
                        string strgoal = "";
                        foreach (DataRow dr in dttemp.Rows)
                        {
                            if (strgoal.IndexOf(dr["guessNum"].ToString()) > -1) continue;
                            if (strgoal == "")
                                strgoal = "'" + dr["guessNum"].ToString() + "'";
                            else
                                strgoal = strgoal + ",'" + dr["guessNum"].ToString() + "'";
                            Application.DoEvents();
                        }
                        strsql1 = "select  * from fbOddTeamResultView where guessNum='"
                                + drall["guessNum"] + "' and instr(type,'客队')>0  and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                        ds = ar.ReturnDataSet(strsql1);
                        if (ds.Tables.Count == 0) continue;
                        dttemp = ds.Tables[0];
                        if (dttemp.Rows.Count == 0) continue;
                        goalmax = 0;
                        goalmin = 99999;
                        goalvmax = 0;
                        goalvmin = 99999;
                        goalmarmax = 0;
                        goalmarmin = 99999;
                        if (dttemp.Rows.Count > 0)
                        {
                            foreach (DataRow drtemp in dttemp.Rows)
                            {
                                if (isbreak) break;
                                if (drtemp["type"].ToString().IndexOf("半场") > -1) continue;
                                if (Convert.ToDouble(drtemp["goalVGame"].ToString()) > goalmax)
                                {
                                    goalmax = Convert.ToDouble(drtemp["goalVGame"].ToString());
                                }
                                if (goalmin > Convert.ToDouble(drtemp["goalVGame"].ToString()))
                                {
                                    goalmin = Convert.ToDouble(drtemp["goalVGame"].ToString());
                                }

                                if (Convert.ToDouble(drtemp["oppGoalVGame"].ToString()) > goalvmax)
                                {
                                    goalvmax = Convert.ToDouble(drtemp["oppGoalVGame"].ToString());
                                }
                                if (goalvmin > Convert.ToDouble(drtemp["oppGoalVGame"].ToString()))
                                {
                                    goalvmin = Convert.ToDouble(drtemp["oppGoalVGame"].ToString());
                                }
                                //if (drtemp["type"].ToString().IndexOf("近六轮") > -1) continue;
                                if (Convert.ToDouble(drtemp["marginGoal"].ToString()) > goalmarmax)
                                {
                                    goalmarmax = Convert.ToDouble(drtemp["marginGoal"].ToString());
                                }
                                if (goalmarmin > Convert.ToDouble(drtemp["marginGoal"].ToString()))
                                {
                                    goalmarmin = Convert.ToDouble(drtemp["marginGoal"].ToString());
                                }
                            }


                        }
                        //strsql1 = "abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
                        //        + ")<1 and abs(oppGoalVGame-"
                        //        + dttemp.Rows[0]["oppGoalVGame"].ToString()lastrankings
                        //        + ")<1 and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1  and oddCompany='" + comboBoxEdit4.Text + "' and type='客队近六轮' and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";
                        //strsql1 = "  abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
                        //    + ")<1 and abs(oppGoalVGame-"
                        //    + dttemp.Rows[0]["oppGoalVGame"].ToString()
                        //    + ")<1 and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1    and oddCompany='" + comboBoxEdit4.Text + "' and type='客队全局' and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";
                        
                        strsql1 = (goalmax + ispan) + " >=CDBL(goalVGame) and CDBL(goalVGame)>=" + (goalmin - ispan) + " and "
                           + (goalvmax + ispan) + ">=CDBL(oppGoalVGame) and CDBL(oppGoalVGame)>=" + (goalvmin - ispan)
                           + " and "
                           + (goalmarmax + ispan) + ">=CDBL(marginGoal) and CDBL(marginGoal)>=" + (goalmarmin - ispan) + "    and oddCompany='" + comboBoxEdit4.Text + "'  and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";

                        strsql2 = "   guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   ) and  guessNum in (" + strgoal + ")";
                        strsql1 = "select * from  fb_gamelist where  " + strsql2 + "    and intime<dateadd('h',-1, cdate('" + drall["intime"] + "')) ";
                        //strsql1 = "select * from  fb_gamelist where  " + strsql2 + "     ";
                        ds = ar.ReturnDataSet(strsql1);
                        if (ds.Tables.Count == 0) continue;
                        dttemp = ds.Tables[0];
                        if (dttemp.Rows.Count == 0) continue;
                        strgoal = "";
                        foreach (DataRow dr in dttemp.Rows)
                        {
                            if (strgoal.IndexOf(dr["guessNum"].ToString()) > -1) continue;
                            if (strgoal == "")
                                strgoal = "'" + dr["guessNum"].ToString() + "'";
                            else
                                strgoal = strgoal + ",'" + dr["guessNum"].ToString() + "'";
                            Application.DoEvents();
                        }
                        strsql1 = "select  * from fbOddTeamResultView where guessNum='"
                                + drall["guessNum"] + "' and type='主队主场' and oddCompany='" + comboBoxEdit4.Text + "'  and ((homeGoal='1@0@' and vistorGoal='1@') or (homeGoal='0@1@' and vistorGoal='1@') or (homeGoal='1@' and vistorGoal='0@1@') or (homeGoal='1@2@3@' and vistorGoal='0@1@')  or (homeGoal='0@1@2@3@' and vistorGoal='0@1@')   or (homeGoal='0@1@' and vistorGoal='0@1@2@3@') or (homeGoal='1@' and vistorGoal='1@') or (homeGoal='1@2@' and vistorGoal='1@0@'))  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                        ds = ar.ReturnDataSet(strsql1);
                        if (ds.Tables.Count == 0) continue;
                        dttemp = ds.Tables[0];
                        if (dttemp.Rows.Count == 0) continue;
                        //strsql1 = "abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
                        //        + ")<1 and abs(oppGoalVGame-"
                        //        + dttemp.Rows[0]["oppGoalVGame"].ToString()lastrankings
                        //        + ")<1 and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1  and oddCompany='" + comboBoxEdit4.Text + "' and type='主队近六轮' and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";
                        strsql1 = "  abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
                            + ")<" + comboBoxEdit8.Text + " and abs(oppGoalVGame-"
                            + dttemp.Rows[0]["oppGoalVGame"].ToString()
                            + ")<" + comboBoxEdit8.Text + "  and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1    and oddCompany='" + comboBoxEdit4.Text + "' and type='主队主场'";



                        strsql2 = "   guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   ) and  guessNum in (" + strgoal + ")";
                        strsql1 = "select * from  fb_gamelist where  " + strsql2 + "    and intime<dateadd('h',-1, cdate('" + drall["intime"] + "')) ";
                        //strsql1 = "select * from  fb_gamelist where  " + strsql2 + "     ";
                        ds = ar.ReturnDataSet(strsql1);
                        if (ds.Tables.Count == 0) continue;
                        dttemp = ds.Tables[0];
                        if (dttemp.Rows.Count == 0) continue;
                        strgoal = "";
                        foreach (DataRow dr in dttemp.Rows)
                        {
                            if (strgoal.IndexOf(dr["guessNum"].ToString()) > -1) continue;
                            if (strgoal == "")
                                strgoal = "'" + dr["guessNum"].ToString() + "'";
                            else
                                strgoal = strgoal + ",'" + dr["guessNum"].ToString() + "'";
                            Application.DoEvents();
                        }
                        strsql1 = "select  * from fbOddTeamResultView where guessNum='"
                                + drall["guessNum"] + "' and type='客队客场' and oddCompany='" + comboBoxEdit4.Text + "'  and ((homeGoal='1@0@' and vistorGoal='1@') or (homeGoal='0@1@' and vistorGoal='1@') or (homeGoal='1@' and vistorGoal='0@1@') or (homeGoal='1@2@3@' and vistorGoal='0@1@')  or (homeGoal='0@1@2@3@' and vistorGoal='0@1@')   or (homeGoal='0@1@' and vistorGoal='0@1@2@3@') or (homeGoal='1@' and vistorGoal='1@') or (homeGoal='1@2@' and vistorGoal='1@0@'))  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                        ds = ar.ReturnDataSet(strsql1);
                        if (ds.Tables.Count == 0) continue;
                        dttemp = ds.Tables[0];
                        if (dttemp.Rows.Count == 0) continue;
                        //strsql1 = "abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
                        //        + ")<1 and abs(oppGoalVGame-"
                        //        + dttemp.Rows[0]["oppGoalVGame"].ToString()lastrankings
                        //        + ")<1 and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1  and oddCompany='" + comboBoxEdit4.Text + "' and type='客队近六轮' and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";
                        strsql1 = "  abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
                            + ")<" + comboBoxEdit8.Text + "  and abs(oppGoalVGame-"
                            + dttemp.Rows[0]["oppGoalVGame"].ToString()
                            + ")<" + comboBoxEdit8.Text + "  and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1   and oddCompany='" + comboBoxEdit4.Text + "' and type='客队客场'  ";

                        strsql2 = "   guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   ) and  guessNum in (" + strgoal + ")";
                        strsql1 = "select * from  fb_gamelist where  " + strsql2 + "    and intime<dateadd('h',-1, cdate('" + drall["intime"] + "')) ";
                        //strsql1 = "select * from  fb_gamelist where  " + strsql2 + "     ";
                        ds = ar.ReturnDataSet(strsql1);
                        if (ds.Tables.Count == 0) continue;
                        dttemp = ds.Tables[0];
                        if (dttemp.Rows.Count == 0) continue;

                        strgoal = "";
                        foreach (DataRow dr in dttemp.Rows)
                        {

                            if (dr["homeTeamName"].ToString().IndexOf(")") > -1)
                            {
                                homeTeamName = dr["homeTeamName"].ToString().Substring(dr["homeTeamName"].ToString().IndexOf("(") + 1, dr["homeTeamName"].ToString().IndexOf(")") - dr["homeTeamName"].ToString().IndexOf("(") - 1).Replace(" ", "");
                                vistortTeamName = dr["vistortTeamName"].ToString().Substring(dr["vistortTeamName"].ToString().IndexOf("(") + 1, dr["vistortTeamName"].ToString().IndexOf(")") - dr["vistortTeamName"].ToString().IndexOf("(") - 1).Replace(" ", "");

                            }
                            else
                            {
                                homeTeamName = dr["homeTeamName"].ToString();
                                vistortTeamName = dr["vistortTeamName"].ToString();

                            }
                            dttimetemp = Convert.ToDateTime(dr["inTime"].ToString());
                            time = dttimetemp.ToString("yyyy-MM");
                            //time = dr["inTime"].ToString().Substring(0, dr["inTime"].ToString().LastIndexOf("-"));
                            homeTeamName = homeTeamName.Replace(" ", "");
                            vistortTeamName = vistortTeamName.Replace(" ", "");
                            if (hsteam.ContainsKey(homeTeamName + "-" + vistortTeamName + "-" + time) == false && dr["guessNum"].ToString() != comboBoxEdit3.Text && dr["GameScore"].ToString() != "" && dr["GameScore"].ToString() != "no match")
                            {
                                if (hsscore.Contains(dr["GameScore"]))
                                {
                                    j = Convert.ToInt32(hsscore[dr["GameScore"]]);
                                    j++;
                                    hsscore[dr["GameScore"]] = j;
                                    hsdate[dr["GameScore"]] = hsdate[dr["GameScore"]] + dr["guessNum"].ToString() + "-" + dr["league"].ToString();
                                }
                                else
                                {
                                   
                                    hsscore.Add(dr["GameScore"], 1);
                                    hsdate.Add(dr["GameScore"], dr["guessNum"] + "-" + dr["league"]);
                                }
                                hsteam.Add(homeTeamName + "-" + vistortTeamName + "-" + time, 1);
                                hsnum.Add(dr["guessNum"], 1);
                                hsGameResult.Add(dr["guessNum"],dr["gameReasult"] );
                            }
                            Application.DoEvents();
                            if (hsbqteam.ContainsKey(homeTeamName + "-" + vistortTeamName + "-" + time) == false && dr["guessNum"].ToString() != comboBoxEdit3.Text && dr["bqgameReasult"].ToString() != "" && dr["bqgameReasult"].ToString() != "no match")
                            {



                                if (hsbq.Contains(dr["bqgameReasult"]))
                                {
                                    j = Convert.ToInt32(hsbq[dr["bqgameReasult"]]);
                                    j++;
                                    hsbq[dr["bqgameReasult"]] = j;
                                    hsbqdate[dr["bqgameReasult"]] = hsbqdate[dr["bqgameReasult"]] + dr["guessNum"].ToString() + "-" + dr["league"].ToString();
                                }
                                else
                                {
                                    hsbq.Add(dr["bqgameReasult"], 1);
                                    hsbqdate.Add(dr["bqgameReasult"], dr["guessNum"] + "-" + dr["league"]);
                                }
                                hsbqteam.Add(homeTeamName + "-" + vistortTeamName + "-" + time, 1);
                                hsbqnum.Add(dr["guessNum"], 1);


                            }
                            Application.DoEvents();
                        }
                        ArrayList akeys = new ArrayList(hsscore.Keys);
                        ArrayList keysresult = new ArrayList(hsGameResult.Keys);
                        int index = 0;
                        int imax = 0;
                        int icount = 0;
                        string strnum = "";
                        if (akeys.Count>1||akeys.Count==0)
                        {
                            continue;
                        }
                        strsql1 = "select  * from fb_teamdata where gamedate='"
                                + drall["guessNum"] + "'   and (jxwinper<>'100' or jxdrawper<>'100' or jxloseper<>'100') order by CDate(fb_teamdata.inTime) desc     ";
                        ds = ar.ReturnDataSet(strsql1);
                        if (ds.Tables.Count == 0) continue;
                        dttemp = ds.Tables[0];
                        if (dttemp.Rows.Count == 0) continue;
                        string strTemp = "";
                        if (dttemp.Rows[0]["jxResult"].ToString() == hsGameResult[keysresult[0]].ToString())
                        {
                            strTemp = "$$";
                            //continue;
                        }
                        for (index = 0; index < akeys.Count; )
                        {
                            imax = 0;
                            for (j = 0; j < akeys.Count; j++)
                            {

                                if (strgoal.IndexOf(akeys[j].ToString()) == -1)
                                {
                                    icount = Convert.ToInt32(hsscore[akeys[j]]);
                                    if (imax < icount)
                                    {
                                        imax = icount;
                                        strnum = akeys[j].ToString() + "(" + imax + ")\r\n" + hsdate[akeys[j]].ToString() + "\r\n";

                                    }
                                }

                            }

                            if (strgoal == "")
                            {
                                strgoal = strnum;
                            }
                            else
                            {
                                strgoal = strgoal + "," + strnum;

                            }
                            index++;
                        }
                        //if (strgoal != "" && (strgoal.IndexOf(",") == -1 || (homeGoal == "1@2@3@4@" && vistorGoal == "0@1@")))
                        //if (strgoal != "")
                        if (strgoal != "")
                        {
                            if (drall["GameScore"].ToString() != "")
                            {
                                memoEdit1.Text = strTemp + drall["league"].ToString() + drall["guessNum"].ToString() + "(" + drall["GameScore"] + ")" + ":" + strgoal + "\r\n" + "homeGoal:" + homeGoal + "\r\n" + "vistorGoal:" + vistorGoal + "\r\n\r\n" + memoEdit1.Text;
                                if (strgoal.IndexOf(drall["GameScore"].ToString()) > -1 && strgoal != "") iright++;
                                iall++;
                            }
                            else
                            {
                                memoEdit1.Text = drall["league"].ToString() + drall["guessNum"].ToString() + ":" + strgoal + "\r\n" + "homeGoal:" + homeGoal + "\r\n" + "vistorGoal:" + vistorGoal + "\r\n\r\n" + memoEdit1.Text;
                                iall++;
                            }

                            Application.DoEvents();
                        }
                    


                //    akeys = new ArrayList(hsbq.Keys);
                //    index = 0;
                //    imax = 0;
                //    icount = 0;
                //    strnum = "";
                //    strgoal = "";
                //    for (index = 0; index < akeys.Count; )
                //    {
                //        imax = 0;
                //        for (j = 0; j < akeys.Count; j++)
                //        {
                //            if (strgoal.IndexOf(akeys[j].ToString()) == -1)
                //            {
                //                icount = Convert.ToInt32(hsbq[akeys[j]]);
                //                if (imax < icount)
                //                {
                //                    imax = icount;
                //                    strnum = akeys[j].ToString() + "(" + imax + ")\r\n " + hsbqdate[akeys[j]].ToString() + "\r\n";

                //                }
                //            }

                //        }

                //        if (strgoal == "")
                //        {
                //            strgoal = strnum;
                //        }
                //        else
                //        {
                //            strgoal = strgoal + "," + strnum;

                //        }
                //        index++;
                //    }
                //    //if (strgoal != "" && (strgoal.IndexOf(",") == -1 || (homeGoal == "1@2@3@4@" && vistorGoal == "0@1@")))
                //    //if (strgoal != "")
                //    if (strgoal != "")
                //    {
                //        if (drall["bqgameReasult"].ToString() != "")
                //        {
                //            memoEdit1.Text = drall["league"].ToString() + drall["guessNum"].ToString() + "(" + drall["bqgameReasult"] + ")" +  ":" + strgoal + "\r\n" + "homeGoal:" + homeGoal + "\r\n" + "vistorGoal:" + vistorGoal + "\r\n\r\n" + memoEdit1.Text;
                //            if (strgoal.IndexOf(drall["bqgameReasult"].ToString()) > -1 && strgoal != "") iright++;
                //            iall++;
                //        }
                //        else
                //        {
                //            memoEdit1.Text = drall["league"].ToString() + drall["guessNum"].ToString() + ":" + strgoal + "\r\n" + "homeGoal:" + homeGoal + "\r\n" + "vistorGoa:" + vistorGoal + "\r\n\r\n" + memoEdit1.Text;
                //            iall++;
                //        }

                //        Application.DoEvents();
                //    }
                  }
                    memoEdit1.Text = dtdate["gameDate"].ToString() + ":" + iright + ":" + iall + "\r\n" + "\r\n\r\n" + memoEdit1.Text;
                //    iright = 0;
                //    iall = 0;
                //    foreach (DataRow drall in dtall.Rows)
                //    {

                //        if (isbreak) break;
                //        this.Text = "" + drall["guessNum"] + ":" + iright + "(" + iall + ")";
                //        strsql1 = "select  * from fbOddTeamResultView where guessNum='"
                //                + drall["guessNum"] + "' and instr(type,'主队')>0 and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                //        ds = ar.ReturnDataSet(strsql1);
                //        if (ds.Tables.Count == 0) continue;
                //        string strgoal = "";
                //        DataTable dttemp = ds.Tables[0];
                //        if (dttemp.Rows.Count == 0) continue;
                //        Hashtable hsscore = new Hashtable();
                //        Hashtable hsteam = new Hashtable();
                //        Hashtable hsnum = new Hashtable();
                //        Hashtable hsdate = new Hashtable();
                //        homeGoal = dttemp.Rows[0]["homeGoal"].ToString();
                //        vistorGoal = dttemp.Rows[0]["vistorGoal"].ToString();
                //        string homeTeamName = dttemp.Rows[0]["homeTeamName"].ToString().Substring(dttemp.Rows[0]["homeTeamName"].ToString().IndexOf("(") + 1, dttemp.Rows[0]["homeTeamName"].ToString().IndexOf(")") - dttemp.Rows[0]["homeTeamName"].ToString().IndexOf("(") - 1).Replace(" ", "");
                //        string vistortTeamName = dttemp.Rows[0]["vistortTeamName"].ToString().Substring(dttemp.Rows[0]["vistortTeamName"].ToString().IndexOf("(") + 1, dttemp.Rows[0]["vistortTeamName"].ToString().IndexOf(")") - dttemp.Rows[0]["vistortTeamName"].ToString().IndexOf("(") - 1).Replace(" ", "");
                //        string time = dttemp.Rows[0]["fb_gamelist.inTime"].ToString().Substring(0, dttemp.Rows[0]["fb_gamelist.inTime"].ToString().LastIndexOf("-"));
                //        homeTeamName = homeTeamName.Replace(" ", "");
                //        vistortTeamName = vistortTeamName.Replace(" ", "");
                //        if (hsteam.ContainsKey(homeTeamName + "-" + vistortTeamName + "-" + time) == false) hsteam.Add(homeTeamName + "-" + vistortTeamName + "-" + time, 1);


                //        strsql1 = "select  * from fbOddTeamResultView where guessNum='"
                //                + drall["guessNum"] + "' and type='主队上半场' and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                //        ds = ar.ReturnDataSet(strsql1);
                //        if (ds.Tables.Count == 0) continue;
                //        dttemp = ds.Tables[0];
                //        strsql1 = "  abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
                //            + ")<1.1 and abs(oppGoalVGame-"
                //            + dttemp.Rows[0]["oppGoalVGame"].ToString()
                //            + ")<1.1 and abs(marginGoal-(" + dttemp.Rows[0]["marginGoal"].ToString() + "))<1    and oddCompany='" + comboBoxEdit4.Text + "' and type='主队上半场' and ((homeGoal='1@0@' and vistorGoal='1@') or (homeGoal='0@1@' and vistorGoal='1@') or (homeGoal='1@' and vistorGoal='0@1@') or (homeGoal='1@2@3@' and vistorGoal='0@1@')  or (homeGoal='0@1@2@3@' and vistorGoal='0@1@')   or (homeGoal='0@1@' and vistorGoal='0@1@2@3@') or (homeGoal='1@' and vistorGoal='1@') or (homeGoal='1@2@' and vistorGoal='1@0@')) ";
                //        strsql2 = "   guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   ) ";
                //        strsql1 = "select * from  fb_gamelist where   " + strsql2 + "    and intime<dateadd('h',-1, cdate('" + drall["intime"] + "')) ";
                //        ds = ar.ReturnDataSet(strsql1);
                //        if (ds.Tables.Count == 0) continue;
                //        dttemp = ds.Tables[0];
                //        if (dttemp.Rows.Count == 0) continue;
                //        strgoal = "";
                //        foreach (DataRow dr in dttemp.Rows)
                //        {
                //            if (strgoal.IndexOf(dr["guessNum"].ToString()) > -1) continue;
                //            if (strgoal == "")
                //                strgoal = "'" + dr["guessNum"].ToString() + "'";
                //            else
                //                strgoal = strgoal + ",'" + dr["guessNum"].ToString() + "'";
                //            Application.DoEvents();
                //        }
                //        strsql1 = "select  * from fbOddTeamResultView where guessNum='"
                //                + drall["guessNum"] + "' and type='主队下半场' and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                //        ds = ar.ReturnDataSet(strsql1);
                //        if (ds.Tables.Count == 0) continue;
                //        dttemp = ds.Tables[0];
                //        strsql1 = "  abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
                //            + ")<1.1 and abs(oppGoalVGame-"
                //            + dttemp.Rows[0]["oppGoalVGame"].ToString()
                //            + ")<1.1 and abs(marginGoal-(" + dttemp.Rows[0]["marginGoal"].ToString() + "))<1   and oddCompany='" + comboBoxEdit4.Text + "' and type='主队下半场'  ";

                //        strsql2 = "   guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   ) and  guessNum in (" + strgoal + ")";
                //        strsql1 = "select * from  fb_gamelist where   " + strsql2 + "    and intime<dateadd('h',-1, cdate('" + drall["intime"] + "')) ";
                //        ds = ar.ReturnDataSet(strsql1);
                //        if (ds.Tables.Count == 0) continue;
                //        dttemp = ds.Tables[0];
                //        if (dttemp.Rows.Count == 0) continue;
                //        strgoal = "";
                //        foreach (DataRow dr in dttemp.Rows)
                //        {
                //            if (strgoal.IndexOf(dr["guessNum"].ToString()) > -1) continue;
                //            if (strgoal == "")
                //                strgoal = "'" + dr["guessNum"].ToString() + "'";
                //            else
                //                strgoal = strgoal + ",'" + dr["guessNum"].ToString() + "'";
                //            Application.DoEvents();
                //        }
                //        strsql1 = "select  * from fbOddTeamResultView where guessNum='"
                //                + drall["guessNum"] + "' and type='客队上半场' and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                //        ds = ar.ReturnDataSet(strsql1);
                //        if (ds.Tables.Count == 0) continue;
                //        dttemp = ds.Tables[0];
                //        strsql1 = "  abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
                //            + ")<1.1 and abs(oppGoalVGame-"
                //            + dttemp.Rows[0]["oppGoalVGame"].ToString()
                //            + ")<1.1 and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1   and oddCompany='" + comboBoxEdit4.Text + "' and type='客队上半场'  ";

                //        strsql2 = "   guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   ) and  guessNum in (" + strgoal + ")";
                //        strsql1 = "select * from  fb_gamelist where   " + strsql2 + "    and intime<dateadd('h',-1, cdate('" + drall["intime"] + "')) ";
                //        ds = ar.ReturnDataSet(strsql1);
                //        if (ds.Tables.Count == 0) continue;
                //        dttemp = ds.Tables[0];
                //        if (dttemp.Rows.Count == 0) continue;
                //        strgoal = "";
                //        foreach (DataRow dr in dttemp.Rows)
                //        {
                //            if (strgoal.IndexOf(dr["guessNum"].ToString()) > -1) continue;
                //            if (strgoal == "")
                //                strgoal = "'" + dr["guessNum"].ToString() + "'";
                //            else
                //                strgoal = strgoal + ",'" + dr["guessNum"].ToString() + "'";
                //            Application.DoEvents();
                //        }
                //        strsql1 = "select  * from fbOddTeamResultView where guessNum='"
                //                + drall["guessNum"] + "' and type='客队下半场' and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                //        ds = ar.ReturnDataSet(strsql1);
                //        if (ds.Tables.Count == 0) continue;
                //        dttemp = ds.Tables[0];
                //        strsql1 = "  abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
                //            + ")<1.1 and abs(oppGoalVGame-"
                //            + dttemp.Rows[0]["oppGoalVGame"].ToString()
                //            + ")<1.1 and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1   and oddCompany='" + comboBoxEdit4.Text + "' and type='客队下半场'  ";

                //        strsql2 = "   guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   ) and  guessNum in (" + strgoal + ")";
                //        strsql1 = "select * from  fb_gamelist where   " + strsql2 + "    and intime<dateadd('h',-1, cdate('" + drall["intime"] + "')) ";
                //        ds = ar.ReturnDataSet(strsql1);
                //        if (ds.Tables.Count == 0) continue;
                //        dttemp = ds.Tables[0];
                //        if (dttemp.Rows.Count == 0) continue;
                //        strgoal = "";
                //        foreach (DataRow dr in dttemp.Rows)
                //        {
                //            homeTeamName = dr["homeTeamName"].ToString().Substring(dr["homeTeamName"].ToString().IndexOf("(") + 1, dr["homeTeamName"].ToString().IndexOf(")") - dr["homeTeamName"].ToString().IndexOf("(") - 1).Replace(" ", "");
                //            vistortTeamName = dr["vistortTeamName"].ToString().Substring(dr["vistortTeamName"].ToString().IndexOf("(") + 1, dr["vistortTeamName"].ToString().IndexOf(")") - dr["vistortTeamName"].ToString().IndexOf("(") - 1).Replace(" ", "");
                //            time = dr["inTime"].ToString().Substring(0, dr["inTime"].ToString().LastIndexOf("-"));
                //            homeTeamName = homeTeamName.Replace(" ", "");
                //            vistortTeamName = vistortTeamName.Replace(" ", "");
                //            if (hsteam.ContainsKey(homeTeamName + "-" + vistortTeamName + "-" + time) == false && dr["guessNum"].ToString() != comboBoxEdit3.Text && dr["GameScore"].ToString() != "" && dr["GameScore"].ToString() != "no match")
                //            {
                //                if (hsscore.Contains(dr["bqgameReasult"]))
                //                {
                //                    j = Convert.ToInt32(hsscore[dr["bqgameReasult"]]);
                //                    j++;
                //                    hsscore[dr["bqgameReasult"]] = j;
                //                    hsdate[dr["bqgameReasult"]] = hsdate[dr["bqgameReasult"]] + dr["guessNum"].ToString() + "-" + dr["league"].ToString();
                //                }
                //                else
                //                {
                //                    hsscore.Add(dr["bqgameReasult"], 1);
                //                    hsdate.Add(dr["bqgameReasult"], dr["guessNum"] + "-" + dr["league"]);
                //                }
                //                hsteam.Add(homeTeamName + "-" + vistortTeamName + "-" + time, 1);
                //                hsnum.Add(dr["guessNum"], 1);
                //            }
                //            Application.DoEvents();
                //        }

                //        ArrayList akeys = new ArrayList(hsscore.Keys);
                //        int index = 0;
                //        int imax = 0;
                //        int icount = 0;
                //        string strnum = "";
                //        for (index = 0; index < akeys.Count; )
                //        {
                //            imax = 0;
                //            for (j = 0; j < akeys.Count; j++)
                //            {
                //                if (strgoal.IndexOf(akeys[j].ToString()) == -1)
                //                {
                //                    icount = Convert.ToInt32(hsscore[akeys[j]]);
                //                    if (imax < icount)
                //                    {
                //                        imax = icount;
                //                        strnum = akeys[j].ToString() + "(" + imax + ")\r\n " + hsdate[akeys[j]].ToString() + "\r\n";

                //                    }
                //                }

                //            }

                //            if (strgoal == "")
                //            {
                //                strgoal = strnum;
                //            }
                //            else
                //            {
                //                strgoal = strgoal + "," + strnum;

                //            }
                //            index++;
                //        }
                //        if (strgoal != "")
                //        {
                //            if (drall["bqgameReasult"].ToString() != "")
                //            {
                //                memoEdit1.Text = drall["league"].ToString() + drall["guessNum"].ToString() + "(" + drall["bqgameReasult"] + ")" + ":" + strgoal + "\r\n" + "homeGoal:" + homeGoal + "\r\n" + "vistorGoal:" + vistorGoal + "\r\n\r\n" + memoEdit1.Text;
                //                if (strgoal.IndexOf(drall["bqgameReasult"].ToString()) > -1 && strgoal != "") iright++;
                //                iall++;
                //            }
                //            else
                //            {
                //                memoEdit1.Text = drall["league"].ToString() + drall["guessNum"].ToString() + ":" + strgoal + "\r\n" + "homeGoal:" + homeGoal + "\r\n" + "vistorGoa:" + vistorGoal + "\r\n\r\n" + memoEdit1.Text;
                //                iall++;
                //            }

                //            Application.DoEvents();
                //        }
                //        memoEdit1.Text = dtdate["gameDate"].ToString() + ":" + iright + ":" + iall + "\r\n" + "\r\n\r\n" + memoEdit1.Text;
                //    }
              }
            }
            catch (Exception ex) { memoEdit1.Text = ex.Message + "\r\n" + ex.ToString () ; }
            simpleButton5.Text = "....";
            simpleButton5.Enabled = true;
        }


        private void Form1_Load(object sender, EventArgs e)
        {
            DevExpress.Data.CurrencyDataController.DisableThreadingProblemsDetection = true;
            ar = new AccessRead(System.AppDomain.CurrentDomain.BaseDirectory.ToString() + "football.mdb");
            DataSet ds = ar.ReturnDataSet("select distinct gameDate from fb_gamelist where guessType='" + comboBoxEdit1.Text + "' order by gameDate desc ");
            DataTable dt = ds.Tables[0];
            comboBoxEdit2.Properties.Items.Clear();
            comboBoxEdit7.Properties.Items.Clear();
            foreach (DataRow dr in dt.Rows)
            {
                comboBoxEdit2.Properties.Items.Add(dr[0]);
                comboBoxEdit7.Properties.Items.Add(dr[0]);
            }
            if (comboBoxEdit2.Properties.Items.Count > 0)
            {
                comboBoxEdit2.Text = comboBoxEdit2.Properties.Items[0].ToString();
                comboBoxEdit7.Text = comboBoxEdit7.Properties.Items[comboBoxEdit7.Properties.Items.Count - 1].ToString();
                ds = ar.ReturnDataSet("select distinct guessNum from fb_gamelist where guessType='" + comboBoxEdit1.Text + "' and gameDate='" + comboBoxEdit2.Text + "' order by guessNum  ");
                dt = ds.Tables[0];
                comboBoxEdit3.Properties.Items.Clear();
                foreach (DataRow dr in dt.Rows)
                {
                    comboBoxEdit3.Properties.Items.Add(dr[0]);
                }

                if (comboBoxEdit3.Properties.Items.Count > 0)
                {

                    comboBoxEdit3.Text = comboBoxEdit3.Properties.Items[0].ToString();
                }
            }
        }

        private void comboBoxEdit1_SelectedIndexChanged(object sender, EventArgs e)
        {

            DataSet ds = ar.ReturnDataSet("select distinct gameDate from fb_gamelist where guessType='" + comboBoxEdit1.Text + "' order by gameDate desc ");
            DataTable dt = ds.Tables[0];
            comboBoxEdit2.Properties.Items.Clear();
            comboBoxEdit7.Properties.Items.Clear();
            foreach (DataRow dr in dt.Rows)
            {
                comboBoxEdit2.Properties.Items.Add(dr[0]);
                comboBoxEdit7.Properties.Items.Add(dr[0]);
            }
            if (comboBoxEdit2.Properties.Items.Count > 0)
            {
                comboBoxEdit2.Text = comboBoxEdit2.Properties.Items[0].ToString();
                comboBoxEdit7.Text = comboBoxEdit7.Properties.Items[comboBoxEdit7.Properties.Items.Count - 1].ToString();
                ds = ar.ReturnDataSet("select distinct guessNum from fb_gamelist where guessType='" + comboBoxEdit1.Text + "' and  gameDate='" + comboBoxEdit2.Text + "' order by guessNum  ");
                dt = ds.Tables[0];
                comboBoxEdit3.Properties.Items.Clear();
                foreach (DataRow dr in dt.Rows)
                {
                    comboBoxEdit3.Properties.Items.Add(dr[0]);
                }

                if (comboBoxEdit3.Properties.Items.Count > 0)
                {

                    comboBoxEdit3.Text = comboBoxEdit3.Properties.Items[0].ToString();
                }
            }
        }

        private void comboBoxEdit2_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataSet ds = ar.ReturnDataSet("select distinct guessNum from fb_gamelist where guessType='" + comboBoxEdit1.Text + "' and gameDate='" + comboBoxEdit2.Text + "' order by guessNum  ");
            DataTable dt = ds.Tables[0];
            comboBoxEdit3.Properties.Items.Clear();
            foreach (DataRow dr in dt.Rows)
            {
                comboBoxEdit3.Properties.Items.Add(dr[0]);
            }

            if (comboBoxEdit3.Properties.Items.Count > 0)
            {

                comboBoxEdit3.Text = comboBoxEdit3.Properties.Items[0].ToString();
            }
        }

        private void comboBoxEdit3_TextChanged(object sender, EventArgs e)
        {
            DataSet ds = ar.ReturnDataSet("select  * from fbOddTeamResultView where guessNum='" + comboBoxEdit3.Text + "' and oddCompany='" + comboBoxEdit4.Text + "' order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc         ");
            DataTable dttemp = ds.Tables[0];
            int i = 1;
            dttemp.Columns.Add("index");
            //foreach (DataRow dr in dttemp.Rows)
            //{
            //    dr["index"] = i++;
            //}

            DataTable dt = dttemp.Clone();
            dt.Rows.Clear();
            DataRow dr = dt.NewRow();

            foreach (DataRow drtemp in dttemp.Rows)
            {
                if (drtemp["type"].ToString() == "主队全局")
                {
                    foreach (DataColumn dc in dt.Columns)
                    {
                        dr[dc.ColumnName] = drtemp[dc.ColumnName];
                    }
                    break;
                }
            }
            dr["index"] = i++;
            dt.Rows.Add(dr);

            dr = dt.NewRow();
            foreach (DataRow drtemp in dttemp.Rows)
            {
                if (drtemp["type"].ToString() == "客队全局")
                {
                    foreach (DataColumn dc in dt.Columns)
                    {
                        dr[dc.ColumnName] = drtemp[dc.ColumnName];
                    }
                    break;
                }
            }
            dr["index"] = i++;
            dt.Rows.Add(dr);

            dr = dt.NewRow();
            foreach (DataRow drtemp in dttemp.Rows)
            {
                if (drtemp["type"].ToString() == "主队主场")
                {
                    foreach (DataColumn dc in dt.Columns)
                    {
                        dr[dc.ColumnName] = drtemp[dc.ColumnName];
                    }
                    break;
                }
            }
            dr["index"] = i++;
            dt.Rows.Add(dr);

            dr = dt.NewRow();
            foreach (DataRow drtemp in dttemp.Rows)
            {
                if (drtemp["type"].ToString() == "客队客场")
                {
                    foreach (DataColumn dc in dt.Columns)
                    {
                        dr[dc.ColumnName] = drtemp[dc.ColumnName];
                    }
                    break;
                }
            }
            dr["index"] = i++;
            dt.Rows.Add(dr);

            dr = dt.NewRow();
            foreach (DataRow drtemp in dttemp.Rows)
            {
                if (drtemp["type"].ToString() == "主队近六轮")
                {
                    foreach (DataColumn dc in dt.Columns)
                    {
                        dr[dc.ColumnName] = drtemp[dc.ColumnName];
                    }
                    break;
                }
            }
            dr["index"] = i++;
            dt.Rows.Add(dr);

            dr = dt.NewRow();
            foreach (DataRow drtemp in dttemp.Rows)
            {
                if (drtemp["type"].ToString() == "客队近六轮")
                {
                    foreach (DataColumn dc in dt.Columns)
                    {
                        dr[dc.ColumnName] = drtemp[dc.ColumnName];
                    }
                    break;
                }
            }
            dr["index"] = i++;
            dt.Rows.Add(dr);

            dr = dt.NewRow();
            foreach (DataRow drtemp in dttemp.Rows)
            {
                if (drtemp["type"].ToString() == "主队上半场")
                {
                    foreach (DataColumn dc in dt.Columns)
                    {
                        dr[dc.ColumnName] = drtemp[dc.ColumnName];
                    }
                    break;
                }
            }
            dr["index"] = i++;
            dt.Rows.Add(dr);

            dr = dt.NewRow();
            foreach (DataRow drtemp in dttemp.Rows)
            {
                if (drtemp["type"].ToString() == "客队上半场")
                {
                    foreach (DataColumn dc in dt.Columns)
                    {
                        dr[dc.ColumnName] = drtemp[dc.ColumnName];
                    }
                    break;
                }
            }
            dr["index"] = i++;
            dt.Rows.Add(dr);


            dr = dt.NewRow();
            foreach (DataRow drtemp in dttemp.Rows)
            {
                if (drtemp["type"].ToString() == "主队下半场")
                {
                    foreach (DataColumn dc in dt.Columns)
                    {
                        dr[dc.ColumnName] = drtemp[dc.ColumnName];
                    }
                    break;
                }
            }
            dr["index"] = i++;
            dt.Rows.Add(dr);

            dr = dt.NewRow();
            foreach (DataRow drtemp in dttemp.Rows)
            {
                if (drtemp["type"].ToString() == "客队下半场")
                {
                    foreach (DataColumn dc in dt.Columns)
                    {
                        dr[dc.ColumnName] = drtemp[dc.ColumnName];
                    }
                    break;
                }
            }
            dr["index"] = i++;
            dt.Rows.Add(dr);
            gridControl1.DataSource = dt;
            //simpleButton1_Click(sender, null);
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            string strsql1 = "";
            string strsql2 = "";
            DataSet ds = null;
            DataTable dt = null;
            try
            {
                if (checkEdit1.Checked)
                {
                    strsql1 = "select * from fbOddTeamResultView where guessNum='"
                         + comboBoxEdit3.Text + "' and type='主队全局' and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                    ds = ar.ReturnDataSet(strsql1);
                    dt = ds.Tables[0];
                    strsql1 = "abs(goalVGame-" + dt.Rows[0]["goalVGame"].ToString()
                        + ")<0.5 and abs(oppGoalVGame-"
                        + dt.Rows[0]["oppGoalVGame"].ToString()
                        + ")<0.5 and abs(marginGoal-" + dt.Rows[0]["marginGoal"].ToString() + ")<3   and oddCompany='" + comboBoxEdit4.Text + "'  and type='主队全局' and homeGoal='" + dt.Rows[0]["homeGoal"] + "' and vistorGoal='" + dt.Rows[0]["vistorGoal"] + "' ";
                    if (strsql2 == "")
                        strsql2 += " guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   )";
                    else
                        strsql2 += " and guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   )";

                }
                if (checkEdit2.Checked)
                {
                    strsql1 = "select  * from fbOddTeamResultView where guessNum='"
                         + comboBoxEdit3.Text + "' and type='客队全局'  and oddCompany='" + comboBoxEdit4.Text + "'order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc      ";
                    ds = ar.ReturnDataSet(strsql1);
                    dt = ds.Tables[0];
                    strsql1 = "abs(goalVGame-" + dt.Rows[0]["goalVGame"].ToString()
                        + ")<0.5 and abs(oppGoalVGame-"
                        + dt.Rows[0]["oppGoalVGame"].ToString()
                        + ")<0.5 and abs(marginGoal-" + dt.Rows[0]["marginGoal"].ToString() + ")<3  and oddCompany='" + comboBoxEdit4.Text + "' and type='客队全局' and homeGoal='" + dt.Rows[0]["homeGoal"] + "' and vistorGoal='" + dt.Rows[0]["vistorGoal"] + "' ";
                    if (strsql2 == "")
                        strsql2 += " guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   )";
                    else
                        strsql2 += " and guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   )";


                }
                if (checkEdit3.Checked)
                {
                    strsql1 = "select  * from fbOddTeamResultView where guessNum='"
                         + comboBoxEdit3.Text + "' and type='主队主场' and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                    ds = ar.ReturnDataSet(strsql1);
                    dt = ds.Tables[0];
                    strsql1 = "abs(goalVGame-" + dt.Rows[0]["goalVGame"].ToString()
                        + ")<0.5 and abs(oppGoalVGame-"
                        + dt.Rows[0]["oppGoalVGame"].ToString()
                        + ")<0.5 and abs(marginGoal-" + dt.Rows[0]["marginGoal"].ToString() + ")<3  and oddCompany='" + comboBoxEdit4.Text + "' and type='主队主场' and homeGoal='" + dt.Rows[0]["homeGoal"] + "' and vistorGoal='" + dt.Rows[0]["vistorGoal"] + "' ";
                    if (strsql2 == "")
                        strsql2 += " guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   )";
                    else
                        strsql2 += " and  guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   )";


                }
                if (checkEdit4.Checked)
                {
                    strsql1 = "select * from fbOddTeamResultView where guessNum='"
                         + comboBoxEdit3.Text + "' and type='客队客场' and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                    ds = ar.ReturnDataSet(strsql1);
                    dt = ds.Tables[0];
                    strsql1 = "abs(goalVGame-" + dt.Rows[0]["goalVGame"].ToString()
                        + ")<0.5 and abs(oppGoalVGame-"
                        + dt.Rows[0]["oppGoalVGame"].ToString()
                        + ")<0.5 and abs(marginGoal-" + dt.Rows[0]["marginGoal"].ToString() + ")<3  and oddCompany='" + comboBoxEdit4.Text + "' and type='客队客场' and homeGoal='" + dt.Rows[0]["homeGoal"] + "' and vistorGoal='" + dt.Rows[0]["vistorGoal"] + "' ";
                    if (strsql2 == "")
                        strsql2 += " guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   )";
                    else
                        strsql2 += " and  guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   )";


                }
                if (checkEdit5.Checked)
                {
                    strsql1 = "select  * from fbOddTeamResultView where guessNum='"
                         + comboBoxEdit3.Text + "' and type='主队近六轮' and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                    ds = ar.ReturnDataSet(strsql1);
                    dt = ds.Tables[0];
                    strsql1 = "abs(goalVGame-" + dt.Rows[0]["goalVGame"].ToString()
                        + ")<0.5 and abs(oppGoalVGame-"
                        + dt.Rows[0]["oppGoalVGame"].ToString()
                        + ")<0.5 and abs(marginGoal-" + dt.Rows[0]["marginGoal"].ToString() + ")<3 and  oddCompany='" + comboBoxEdit4.Text + "' and type='主队近六轮' and homeGoal='" + dt.Rows[0]["homeGoal"] + "' and vistorGoal='" + dt.Rows[0]["vistorGoal"] + "' ";
                    if (strsql2 == "")
                        strsql2 += " guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   )";
                    else
                        strsql2 += " and  guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   )";


                }
                if (checkEdit6.Checked)
                {
                    strsql1 = "select * from fbOddTeamResultView where guessNum='"
                         + comboBoxEdit3.Text + "' and type='客队近六轮' and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                    ds = ar.ReturnDataSet(strsql1);
                    dt = ds.Tables[0];
                    strsql1 = "abs(goalVGame-" + dt.Rows[0]["goalVGame"].ToString()
                        + ")<" + comboBoxEdit8.Text + "  and abs(oppGoalVGame-"
                        + dt.Rows[0]["oppGoalVGame"].ToString()
                        + ")<" + comboBoxEdit8.Text + "  and abs(marginGoal-" + dt.Rows[0]["marginGoal"].ToString() + ")<3 and oddCompany='" + comboBoxEdit4.Text + "' and type='客队近六轮' and homeGoal='" + dt.Rows[0]["homeGoal"] + "' and vistorGoal='" + dt.Rows[0]["vistorGoal"] + "' ";
                    if (strsql2 == "")
                        strsql2 += " guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   )";
                    else
                        strsql2 += " and  guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   )";


                }
                if (strsql2 == "") strsql2 = " guessNum='"
                       + comboBoxEdit3.Text + "'";
                strsql1 = "select * from  fb_gamelist where guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql2 + "   )";
                ds = ar.ReturnDataSet(strsql1);
                dt = ds.Tables[0];
                int i = 1, j = 1;
                dt.Columns.Add("index");
                foreach (DataRow dr in dt.Rows)
                {
                    dr["index"] = i++;
                }
                strsql1 = "select  * from fbOddTeamResultView where guessNum='"
                        + comboBoxEdit3.Text + "' and type='主队近六轮' and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                ds = ar.ReturnDataSet(strsql1);
                DataTable dttemp = ds.Tables[0];
                Hashtable hsscore = new Hashtable();
                Hashtable hsteam = new Hashtable();
                Hashtable hsnum = new Hashtable();
                string homeTeamName = dttemp.Rows[0]["homeTeamName"].ToString().Substring(dttemp.Rows[0]["homeTeamName"].ToString().IndexOf("(") + 1, dttemp.Rows[0]["homeTeamName"].ToString().IndexOf(")") - dttemp.Rows[0]["homeTeamName"].ToString().IndexOf("(") - 1).Replace(" ", "");
                string vistortTeamName = dttemp.Rows[0]["vistortTeamName"].ToString().Substring(dttemp.Rows[0]["vistortTeamName"].ToString().IndexOf("(") + 1, dttemp.Rows[0]["vistortTeamName"].ToString().IndexOf(")") - dttemp.Rows[0]["vistortTeamName"].ToString().IndexOf("(") - 1).Replace(" ", "");
                string time = dttemp.Rows[0]["fb_gamelist.inTime"].ToString().Substring(0, dttemp.Rows[0]["fb_gamelist.inTime"].ToString().LastIndexOf("-"));
                if (hsteam.ContainsKey(homeTeamName + "-" + vistortTeamName + "-" + time) == false) hsteam.Add(homeTeamName + "-" + vistortTeamName + "-" + time, 1);
                strsql1 = "abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
                        + ")<" + comboBoxEdit8.Text + "  and abs(oppGoalVGame-"
                        + dttemp.Rows[0]["oppGoalVGame"].ToString()
                        + ")<" + comboBoxEdit8.Text + "  and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<3   and oddCompany='" + comboBoxEdit4.Text + "' and type='主队近六轮' and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";

                strsql2 = "   guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   )";
                strsql1 = "select * from  fb_gamelist where guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql2 + "   )";
                ds = ar.ReturnDataSet(strsql1);
                dttemp = ds.Tables[0];
                string strgoal = "";
                foreach (DataRow dr in dttemp.Rows)
                {
                    if (strgoal == "")
                        strgoal = "'" + dr["guessNum"].ToString() + "'";
                    else
                        strgoal = strgoal + ",'" + dr["guessNum"].ToString() + "'";

                    //string homeTeamName = dr["homeTeamName"].ToString().Substring(dr["homeTeamName"].ToString().IndexOf("(")+1, dr["homeTeamName"].ToString().IndexOf(")") - dr["homeTeamName"].ToString().IndexOf("(")-1);
                    //string vistortTeamName = dr["vistortTeamName"].ToString().Substring(dr["vistortTeamName"].ToString().IndexOf("(")+1, dr["vistortTeamName"].ToString().IndexOf(")") - dr["vistortTeamName"].ToString().IndexOf("(")-1);
                    //string time = dr["inTime"].ToString().Substring(0, dr["inTime"].ToString().LastIndexOf("-"));
                    //if (hsteam.ContainsKey(homeTeamName + "-" + vistortTeamName + "-" + time) == false && dr["guessNum"].ToString() != comboBoxEdit3.Text && dr["GameScore"].ToString() != "" && dr["GameScore"].ToString() != "no match")
                    //{
                    //    if (hsscore.Contains(dr["GameScore"]))
                    //    {
                    //        j = Convert.ToInt32(hsscore[dr["GameScore"]]);
                    //        j++;
                    //        hsscore[dr["GameScore"]] =j;
                    //    }
                    //    else
                    //    {
                    //        hsscore.Add(dr["GameScore"], 1);
                    //    }
                    //    hsteam.Add(homeTeamName+"-"+vistortTeamName+"-"+time,1);
                    //}
                }
                strsql1 = "select  * from fbOddTeamResultView where guessNum='"
                        + comboBoxEdit3.Text + "' and type='客队近六轮' and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                ds = ar.ReturnDataSet(strsql1);
                dttemp = ds.Tables[0];
                strsql1 = "abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
                        + ")<" + comboBoxEdit8.Text + "  and abs(oppGoalVGame-"
                        + dttemp.Rows[0]["oppGoalVGame"].ToString()
                        + ")<" + comboBoxEdit8.Text + "  and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<3  and oddCompany='" + comboBoxEdit4.Text + "' and type='客队近六轮' and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";

                strsql2 = "   guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   ) and  guessNum in (" + strgoal + ")";
                strsql1 = "select * from  fb_gamelist where guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql2 + "   )";
                ds = ar.ReturnDataSet(strsql1);
                dttemp = ds.Tables[0];
                strgoal = "";
                foreach (DataRow dr in dttemp.Rows)
                {

                    if (dr["homeTeamName"].ToString().IndexOf(")") > -1)
                    {
                        homeTeamName = dr["homeTeamName"].ToString().Substring(dr["homeTeamName"].ToString().IndexOf("(") + 1, dr["homeTeamName"].ToString().IndexOf(")") - dr["homeTeamName"].ToString().IndexOf("(") - 1).Replace(" ", "");
                        vistortTeamName = dr["vistortTeamName"].ToString().Substring(dr["vistortTeamName"].ToString().IndexOf("(") + 1, dr["vistortTeamName"].ToString().IndexOf(")") - dr["vistortTeamName"].ToString().IndexOf("(") - 1).Replace(" ", "");

                    }
                    else
                    {
                        homeTeamName = dr["homeTeamName"].ToString();
                        vistortTeamName = dr["vistortTeamName"].ToString();

                    }
                    DateTime dttimetemp = Convert.ToDateTime(dr["fb_gamelist.inTime"].ToString());
                    time = dttimetemp.ToString("yyyy-MM");
                    if (hsteam.ContainsKey(homeTeamName + "-" + vistortTeamName + "-" + time) == false && dr["guessNum"].ToString() != comboBoxEdit3.Text && dr["GameScore"].ToString() != "" && dr["GameScore"].ToString() != "no match")
                    {
                        if (hsscore.Contains(dr["GameScore"]))
                        {
                            j = Convert.ToInt32(hsscore[dr["GameScore"]]);
                            j++;
                            hsscore[dr["GameScore"]] = j;
                        }
                        else
                        {
                            hsscore.Add(dr["GameScore"], 1);
                        }
                        hsteam.Add(homeTeamName + "-" + vistortTeamName + "-" + time, 1);
                        hsnum.Add(dr["guessNum"], 1);
                    }
                }
                DataRow drtemp = dt.NewRow();
                drtemp["index"] = i++;
                drtemp["guessNum"] = "合计";
                ArrayList akeys = new ArrayList(hsscore.Keys);
                int index = 0;
                int imax = 0;
                int icount = 0;
                string strnum = "";
                for (index = 0; index < akeys.Count; )
                {
                    imax = 0;
                    for (j = 0; j < akeys.Count; j++)
                    {
                        if (strgoal.IndexOf(akeys[j].ToString()) == -1)
                        {
                            icount = Convert.ToInt32(hsscore[akeys[j]]);
                            if (imax < icount)
                            {
                                strnum = akeys[j].ToString();
                                imax = icount;
                            }
                        }

                    }

                    if (strgoal == "")
                    {
                        strgoal = strnum + "(" + imax + ")";
                    }
                    else
                    {
                        strgoal = strgoal + "," + strnum + "(" + imax + ")";

                    }
                    index++;
                }
                drtemp["league"] = strgoal;
                gridColumn33.ToolTip = strgoal;
                //drtemp["homeTeamName"] = strgoal;
                //drtemp["vistortTeamName"] = strgoal;
                //drtemp["odd"] = strgoal;
                //drtemp["odded"] = strgoal;
                akeys = new ArrayList(hsnum.Keys);
                for (j = 0; j < dt.Rows.Count; )
                {
                    bool isfind = false;
                    for (index = 0; index < akeys.Count; index++)
                    {

                        if (dt.Rows[j]["guessNum"].ToString() == akeys[index].ToString())
                        {
                            isfind = true;
                            break;
                        }
                    }
                    if (!isfind)
                    {
                        dt.Rows.Remove(dt.Rows[j]);
                        j = 0;
                    }
                    else
                        j++;
                }

                dt.Rows.Add(drtemp);
            }
            catch { }
            gridControl2.DataSource = dt;
        }


        private void gridView2_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            if (gridView2.FocusedRowHandle < 0) return;
            DataRow drs = gridView2.GetFocusedDataRow();
            if (drs == null) return;
            if (drs["guessNum"].ToString().IndexOf("合计") > -1) return;
            DataSet ds = ar.ReturnDataSet("select  * from fbOddTeamResultView where guessNum='"
                + drs["guessNum"] + "' and oddCompany='" + comboBoxEdit4.Text + "' order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc      ");
            DataTable dttemp = ds.Tables[0];
            int i = 1;
            dttemp.Columns.Add("index");
            //foreach (DataRow dr in dttemp.Rows)
            //{
            //    dr["index"] = i++;
            //}

            DataTable dt = dttemp.Clone();
            dt.Rows.Clear();
            try
            {
                if (dttemp.Rows.Count > 0)
                {
                    DataRow dr = dt.NewRow();

                    foreach (DataRow drtemp in dttemp.Rows)
                    {
                        if (drtemp["type"].ToString() == "主队全局")
                        {
                            foreach (DataColumn dc in dt.Columns)
                            {
                                dr[dc.ColumnName] = drtemp[dc.ColumnName];
                            }
                        }
                    }
                    dr["index"] = i++;
                    dt.Rows.Add(dr);

                    dr = dt.NewRow();
                    foreach (DataRow drtemp in dttemp.Rows)
                    {
                        if (drtemp["type"].ToString() == "客队全局")
                        {
                            foreach (DataColumn dc in dt.Columns)
                            {
                                dr[dc.ColumnName] = drtemp[dc.ColumnName];
                            }
                        }
                    }
                    dr["index"] = i++;
                    dt.Rows.Add(dr);

                    dr = dt.NewRow();
                    foreach (DataRow drtemp in dttemp.Rows)
                    {
                        if (drtemp["type"].ToString() == "主队主场")
                        {
                            foreach (DataColumn dc in dt.Columns)
                            {
                                dr[dc.ColumnName] = drtemp[dc.ColumnName];
                            }
                        }
                    }
                    dr["index"] = i++;
                    dt.Rows.Add(dr);

                    dr = dt.NewRow();
                    foreach (DataRow drtemp in dttemp.Rows)
                    {
                        if (drtemp["type"].ToString() == "客队客场")
                        {
                            foreach (DataColumn dc in dt.Columns)
                            {
                                dr[dc.ColumnName] = drtemp[dc.ColumnName];
                            }
                        }
                    }
                    dr["index"] = i++;
                    dt.Rows.Add(dr);

                    dr = dt.NewRow();
                    foreach (DataRow drtemp in dttemp.Rows)
                    {
                        if (drtemp["type"].ToString() == "主队近六轮")
                        {
                            foreach (DataColumn dc in dt.Columns)
                            {
                                dr[dc.ColumnName] = drtemp[dc.ColumnName];
                            }
                        }
                    }
                    dr["index"] = i++;
                    dt.Rows.Add(dr);

                    dr = dt.NewRow();
                    foreach (DataRow drtemp in dttemp.Rows)
                    {
                        if (drtemp["type"].ToString() == "客队近六轮")
                        {
                            foreach (DataColumn dc in dt.Columns)
                            {
                                dr[dc.ColumnName] = drtemp[dc.ColumnName];
                            }
                        }
                    }
                    dr["index"] = i++;
                    dt.Rows.Add(dr);

                    dr = dt.NewRow();
                    foreach (DataRow drtemp in dttemp.Rows)
                    {
                        if (drtemp["type"].ToString() == "主队上半场")
                        {
                            foreach (DataColumn dc in dt.Columns)
                            {
                                dr[dc.ColumnName] = drtemp[dc.ColumnName];
                            }
                        }
                    }
                    dr["index"] = i++;
                    dt.Rows.Add(dr);

                    dr = dt.NewRow();
                    foreach (DataRow drtemp in dttemp.Rows)
                    {
                        if (drtemp["type"].ToString() == "客队上半场")
                        {
                            foreach (DataColumn dc in dt.Columns)
                            {
                                dr[dc.ColumnName] = drtemp[dc.ColumnName];
                            }
                        }
                    }
                    dr["index"] = i++;
                    dt.Rows.Add(dr);


                    dr = dt.NewRow();
                    foreach (DataRow drtemp in dttemp.Rows)
                    {
                        if (drtemp["type"].ToString() == "主队下半场")
                        {
                            foreach (DataColumn dc in dt.Columns)
                            {
                                dr[dc.ColumnName] = drtemp[dc.ColumnName];
                            }
                        }
                    }
                    dr["index"] = i++;
                    dt.Rows.Add(dr);

                    dr = dt.NewRow();
                    foreach (DataRow drtemp in dttemp.Rows)
                    {
                        if (drtemp["type"].ToString() == "客队下半场")
                        {
                            foreach (DataColumn dc in dt.Columns)
                            {
                                dr[dc.ColumnName] = drtemp[dc.ColumnName];
                            }
                        }
                    }
                    dr["index"] = i++;
                    dt.Rows.Add(dr);
                }
            }
            catch { }
            gridControl3.DataSource = dt;
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            int i = comboBoxEdit3.SelectedIndex;
            if (comboBoxEdit3.Properties.Items.Count > 0)
            {
                if (i - 1 < 0)
                {
                    comboBoxEdit3.SelectedIndex = comboBoxEdit3.Properties.Items.Count - 1;
                }
                else
                {
                    comboBoxEdit3.SelectedIndex = i - 1;

                }
            }

        }

        private void simpleButton3_Click(object sender, EventArgs e)
        {
            int i = comboBoxEdit3.SelectedIndex;
            if (comboBoxEdit3.Properties.Items.Count > 0)
            {
                if (i + 1 >= comboBoxEdit3.Properties.Items.Count)
                {
                    comboBoxEdit3.SelectedIndex = 0;
                }
                else
                {
                    comboBoxEdit3.SelectedIndex = i + 1;

                }
            }
        }

        private void simpleButton4_Click(object sender, EventArgs e)
        {
            simpleButton4.Text = "。。。";
            simpleButton4.Enabled = false;
            isbreak = false;
            string strsql1 = "";
            string strsql2 = "";
            DataSet ds = null;
            DataTable dt = null;
            DataTable dtall = null;
            string homeGoal = "";
            string vistorGoal = "";
            int iright = 0;
            int iall = 0;
            try
            {
                memoEdit1.Text = "";
                if (strsql2 == "") strsql2 = " guessType='" + comboBoxEdit1.Text + "' and guessNum like'%"
                       + comboBoxEdit2.Text + "%'";
                if (checkEdit7.Checked)
                {
                    strsql2 += " and GameScore='' ";
                }
                strsql1 = "select * from  fb_gamelist where  " + strsql2 + " ORDER BY guessNum  ";
                ds = ar.ReturnDataSet(strsql1);
                dtall = ds.Tables[0];
                int i = 1, j = 1;
                foreach (DataRow drall in dtall.Rows)
                {

                    if (isbreak) break;
                    this.Text = "" + drall["guessNum"] + ":" + iright + "(" + iall + ")";
                    strsql1 = "select  * from fbOddTeamResultView where guessNum='"
                            + drall["guessNum"] + "' and instr(type,'主队')>0 and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                    ds = ar.ReturnDataSet(strsql1);
                    if (ds.Tables.Count == 0) continue;
                    DataTable dttemp = ds.Tables[0];
                    if (dttemp.Rows.Count == 0) continue;
                    Hashtable hsscore = new Hashtable();
                    Hashtable hsdate = new Hashtable();
                    Hashtable hsteam = new Hashtable();
                    Hashtable hsnum = new Hashtable();
                    Hashtable hsbqdate = new Hashtable();
                    Hashtable hsGameResult = new Hashtable();
                    Hashtable hsbq = new Hashtable();
                    Hashtable hsbqteam = new Hashtable();
                    Hashtable hsbqnum = new Hashtable();
                    double goalmax = 0, goalmin = 99999, goalvmax = 0, goalvmin = 99999, goalmarmax = 0, goalmarmin = 99999;
                    if (dttemp.Rows.Count > 0)
                    {
                        foreach (DataRow drtemp in dttemp.Rows)
                        {
                            if (isbreak) break;
                            if (drtemp["type"].ToString().IndexOf("半场") > -1) continue;
                            if (Convert.ToDouble(drtemp["goalVGame"].ToString()) > goalmax)
                            {
                                goalmax = Convert.ToDouble(drtemp["goalVGame"].ToString());
                            }
                            if (goalmin > Convert.ToDouble(drtemp["goalVGame"].ToString()))
                            {
                                goalmin = Convert.ToDouble(drtemp["goalVGame"].ToString());
                            }

                            if (Convert.ToDouble(drtemp["oppGoalVGame"].ToString()) > goalvmax)
                            {
                                goalvmax = Convert.ToDouble(drtemp["oppGoalVGame"].ToString());
                            }
                            if (goalvmin > Convert.ToDouble(drtemp["oppGoalVGame"].ToString()))
                            {
                                goalvmin = Convert.ToDouble(drtemp["oppGoalVGame"].ToString());
                            }

                            //if (drtemp["type"].ToString().IndexOf("近六轮") > -1) continue;
                            if (Convert.ToDouble(drtemp["marginGoal"].ToString()) > goalmarmax)
                            {
                                goalmarmax = Convert.ToDouble(drtemp["marginGoal"].ToString());
                            }
                            if (goalmarmin > Convert.ToDouble(drtemp["marginGoal"].ToString()))
                            {
                                goalmarmin = Convert.ToDouble(drtemp["marginGoal"].ToString());
                            }
                        }


                    }

                    homeGoal = dttemp.Rows[0]["homeGoal"].ToString();
                    vistorGoal = dttemp.Rows[0]["vistorGoal"].ToString();
                    string homeTeamName = dttemp.Rows[0]["homeTeamName"].ToString().Substring(dttemp.Rows[0]["homeTeamName"].ToString().IndexOf("(") + 1, dttemp.Rows[0]["homeTeamName"].ToString().IndexOf(")") - dttemp.Rows[0]["homeTeamName"].ToString().IndexOf("(") - 1).Replace(" ", "");
                    string vistortTeamName = dttemp.Rows[0]["vistortTeamName"].ToString().Substring(dttemp.Rows[0]["vistortTeamName"].ToString().IndexOf("(") + 1, dttemp.Rows[0]["vistortTeamName"].ToString().IndexOf(")") - dttemp.Rows[0]["vistortTeamName"].ToString().IndexOf("(") - 1).Replace(" ", "");
                    DateTime dttimetemp = Convert.ToDateTime(dttemp.Rows[0]["fb_gamelist.inTime"].ToString());
                    string  time = dttimetemp.ToString("yyyy-MM");
                    
                    homeTeamName = homeTeamName.Replace(" ", "");
                    vistortTeamName = vistortTeamName.Replace(" ", "");
                    if (hsteam.ContainsKey(homeTeamName + "-" + vistortTeamName + "-" + time) == false) hsteam.Add(homeTeamName + "-" + vistortTeamName + "-" + time, 1);
                    if (hsbqteam.ContainsKey(homeTeamName + "-" + vistortTeamName + "-" + time) == false) hsbqteam.Add(homeTeamName + "-" + vistortTeamName + "-" + time, 1);
                    //strsql1 = "abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
                    //        + ")<1 and abs(oppGoalVGame-"
                    //        + dttemp.Rows[0]["oppGoalVGame"].ToString()
                    //        + ")<1 and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1   and oddCompany='" + comboBoxEdit4.Text + "' and type='主队近六轮' and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";
                    strsql1 = (goalmax + 1) + " >=CDBL(goalVGame) and CDBL(goalVGame)>=" + (goalmin - 1) + " and "
                       + (goalvmax + 1) + ">=CDBL(oppGoalVGame) and CDBL(oppGoalVGame)>=" + (goalvmin - 1)
                       + " and "
                       + (goalmarmax + 1) + ">=CDBL(marginGoal) and CDBL(marginGoal)>=" + (goalmarmin - 1) + "    and oddCompany='" + comboBoxEdit4.Text + "'  and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";

                    strsql2 = "   guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   )";
                    strsql1 = "select * from  fb_gamelist where  " + strsql2 + "    and intime<dateadd('h',-1, cdate('" + drall["intime"] + "')) ";
                    //strsql1 = "select * from  fb_gamelist where  " + strsql2 + "     ";
                    ds = ar.ReturnDataSet(strsql1);
                    if (ds.Tables.Count == 0) continue;
                    dttemp = ds.Tables[0];
                    if (dttemp.Rows.Count == 0) continue;
                    string strgoal = "";
                    foreach (DataRow dr in dttemp.Rows)
                    {
                        if (strgoal.IndexOf(dr["guessNum"].ToString()) > -1) continue;
                        if (strgoal == "")
                            strgoal = "'" + dr["guessNum"].ToString() + "'";
                        else
                            strgoal = strgoal + ",'" + dr["guessNum"].ToString() + "'";
                        Application.DoEvents();
                    }
                    strsql1 = "select  * from fbOddTeamResultView where guessNum='"
                            + drall["guessNum"] + "' and instr(type,'客队')>0  and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                    ds = ar.ReturnDataSet(strsql1);
                    if (ds.Tables.Count == 0) continue;
                    dttemp = ds.Tables[0];
                    if (dttemp.Rows.Count == 0) continue;
                    goalmax = 0;
                    goalmin = 99999;
                    goalvmax = 0;
                    goalvmin = 99999;
                    goalmarmax = 0;
                    goalmarmin = 99999;
                    if (dttemp.Rows.Count > 0)
                    {
                        foreach (DataRow drtemp in dttemp.Rows)
                        {
                            if (isbreak) break;
                            if (drtemp["type"].ToString().IndexOf("半场") > -1) continue;
                            if (Convert.ToDouble(drtemp["goalVGame"].ToString()) > goalmax)
                            {
                                goalmax = Convert.ToDouble(drtemp["goalVGame"].ToString());
                            }
                            if (goalmin > Convert.ToDouble(drtemp["goalVGame"].ToString()))
                            {
                                goalmin = Convert.ToDouble(drtemp["goalVGame"].ToString());
                            }

                            if (Convert.ToDouble(drtemp["oppGoalVGame"].ToString()) > goalvmax)
                            {
                                goalvmax = Convert.ToDouble(drtemp["oppGoalVGame"].ToString());
                            }
                            if (goalvmin > Convert.ToDouble(drtemp["oppGoalVGame"].ToString()))
                            {
                                goalvmin = Convert.ToDouble(drtemp["oppGoalVGame"].ToString());
                            }
                            //if (drtemp["type"].ToString().IndexOf("近六轮") > -1) continue;
                            if (Convert.ToDouble(drtemp["marginGoal"].ToString()) > goalmarmax)
                            {
                                goalmarmax = Convert.ToDouble(drtemp["marginGoal"].ToString());
                            }
                            if (goalmarmin > Convert.ToDouble(drtemp["marginGoal"].ToString()))
                            {
                                goalmarmin = Convert.ToDouble(drtemp["marginGoal"].ToString());
                            }
                        }


                    }
                    //strsql1 = "abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
                    //        + ")<1 and abs(oppGoalVGame-"
                    //        + dttemp.Rows[0]["oppGoalVGame"].ToString()lastrankings
                    //        + ")<1 and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1  and oddCompany='" + comboBoxEdit4.Text + "' and type='客队近六轮' and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";
                    //strsql1 = "  abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
                    //    + ")<1 and abs(oppGoalVGame-"
                    //    + dttemp.Rows[0]["oppGoalVGame"].ToString()
                    //    + ")<1 and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1    and oddCompany='" + comboBoxEdit4.Text + "' and type='客队全局' and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";
                    strsql1 = (goalmax + 1) + " >=CDBL(goalVGame) and CDBL(goalVGame)>=" + (goalmin - 1) + " and "
                       + (goalvmax + 1) + ">=CDBL(oppGoalVGame) and CDBL(oppGoalVGame)>=" + (goalvmin - 1)
                       + " and "
                       + (goalmarmax + 1) + ">=CDBL(marginGoal) and CDBL(marginGoal)>=" + (goalmarmin - 1) + "    and oddCompany='" + comboBoxEdit4.Text + "'  and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";

                    strsql2 = "   guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   ) and  guessNum in (" + strgoal + ")";
                    strsql1 = "select * from  fb_gamelist where  " + strsql2 + "    and intime<dateadd('h',-1, cdate('" + drall["intime"] + "')) ";
                    //strsql1 = "select * from  fb_gamelist where  " + strsql2 + "     ";
                    ds = ar.ReturnDataSet(strsql1);
                    if (ds.Tables.Count == 0) continue;
                    dttemp = ds.Tables[0];
                    if (dttemp.Rows.Count == 0) continue;
                    strgoal = "";
                    foreach (DataRow dr in dttemp.Rows)
                    {
                        if (strgoal.IndexOf(dr["guessNum"].ToString()) > -1) continue;
                        if (strgoal == "")
                            strgoal = "'" + dr["guessNum"].ToString() + "'";
                        else
                            strgoal = strgoal + ",'" + dr["guessNum"].ToString() + "'";
                        Application.DoEvents();
                    }
                    strsql1 = "select  * from fbOddTeamResultView where guessNum='"
                            + drall["guessNum"] + "' and type='主队主场' and oddCompany='" + comboBoxEdit4.Text + "'  and ((homeGoal='1@0@' and vistorGoal='1@') or (homeGoal='0@1@' and vistorGoal='1@') or (homeGoal='1@' and vistorGoal='0@1@') or (homeGoal='1@2@3@' and vistorGoal='0@1@')  or (homeGoal='0@1@2@3@' and vistorGoal='0@1@')   or (homeGoal='0@1@' and vistorGoal='0@1@2@3@') or (homeGoal='1@' and vistorGoal='1@') or (homeGoal='1@2@' and vistorGoal='1@0@'))  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                    ds = ar.ReturnDataSet(strsql1);
                    if (ds.Tables.Count == 0) continue;
                    dttemp = ds.Tables[0];
                    if (dttemp.Rows.Count == 0) continue;
                    //strsql1 = "abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
                    //        + ")<1 and abs(oppGoalVGame-"
                    //        + dttemp.Rows[0]["oppGoalVGame"].ToString()lastrankings
                    //        + ")<1 and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1  and oddCompany='" + comboBoxEdit4.Text + "' and type='主队近六轮' and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";
                    strsql1 = "  abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
                        + ")<" + comboBoxEdit8.Text + "  and abs(oppGoalVGame-"
                        + dttemp.Rows[0]["oppGoalVGame"].ToString()
                        + ")<" + comboBoxEdit8.Text + "  and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1    and oddCompany='" + comboBoxEdit4.Text + "' and type='主队主场' ";



                    strsql2 = "   guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   ) and  guessNum in (" + strgoal + ")";
                    strsql1 = "select * from  fb_gamelist where  " + strsql2 + "    and intime<dateadd('h',-1, cdate('" + drall["intime"] + "')) ";
                    //strsql1 = "select * from  fb_gamelist where  " + strsql2 + "     "; 
                    ds = ar.ReturnDataSet(strsql1);
                    if (ds.Tables.Count == 0) continue;
                    dttemp = ds.Tables[0];
                    if (dttemp.Rows.Count == 0) continue;
                    strgoal = "";
                    foreach (DataRow dr in dttemp.Rows)
                    {
                        if (strgoal.IndexOf(dr["guessNum"].ToString()) > -1) continue;
                        if (strgoal == "")
                            strgoal = "'" + dr["guessNum"].ToString() + "'";
                        else
                            strgoal = strgoal + ",'" + dr["guessNum"].ToString() + "'";
                        Application.DoEvents();
                    }
                    strsql1 = "select  * from fbOddTeamResultView where guessNum='"
                            + drall["guessNum"] + "' and type='客队客场' and oddCompany='" + comboBoxEdit4.Text + "'  and ((homeGoal='1@0@' and vistorGoal='1@') or (homeGoal='0@1@' and vistorGoal='1@') or (homeGoal='1@' and vistorGoal='0@1@') or (homeGoal='1@2@3@' and vistorGoal='0@1@')  or (homeGoal='0@1@2@3@' and vistorGoal='0@1@')   or (homeGoal='0@1@' and vistorGoal='0@1@2@3@') or (homeGoal='1@' and vistorGoal='1@') or (homeGoal='1@2@' and vistorGoal='1@0@'))  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                    ds = ar.ReturnDataSet(strsql1);
                    if (ds.Tables.Count == 0) continue;
                    dttemp = ds.Tables[0];
                    if (dttemp.Rows.Count == 0) continue;
                    //strsql1 = "abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
                    //        + ")<1 and abs(oppGoalVGame-"
                    //        + dttemp.Rows[0]["oppGoalVGame"].ToString()lastrankings
                    //        + ")<1 and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1  and oddCompany='" + comboBoxEdit4.Text + "' and type='客队近六轮' and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";
                    strsql1 = "  abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
                        + ")<" + comboBoxEdit8.Text + "  and abs(oppGoalVGame-"
                        + dttemp.Rows[0]["oppGoalVGame"].ToString()
                        + ")<" + comboBoxEdit8.Text + "  and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1   and oddCompany='" + comboBoxEdit4.Text + "' and type='客队客场'  ";

                    strsql2 = "   guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   ) and  guessNum in (" + strgoal + ")";
                    strsql1 = "select * from  fb_gamelist where  " + strsql2 + "    and intime<dateadd('h',-1, cdate('" + drall["intime"] + "')) ";
                    //strsql1 = "select * from  fb_gamelist where  " + strsql2 + "     ";
                    ds = ar.ReturnDataSet(strsql1);
                    if (ds.Tables.Count == 0) continue;
                    dttemp = ds.Tables[0];
                    if (dttemp.Rows.Count == 0) continue;

                    strgoal = "";
                    foreach (DataRow dr in dttemp.Rows)
                    {
                        if (dr["homeTeamName"].ToString().IndexOf(")")>-1)
                        {
                            homeTeamName = dr["homeTeamName"].ToString().Substring(dr["homeTeamName"].ToString().IndexOf("(") + 1, dr["homeTeamName"].ToString().IndexOf(")") - dr["homeTeamName"].ToString().IndexOf("(") - 1).Replace(" ", "");
                            vistortTeamName = dr["vistortTeamName"].ToString().Substring(dr["vistortTeamName"].ToString().IndexOf("(") + 1, dr["vistortTeamName"].ToString().IndexOf(")") - dr["vistortTeamName"].ToString().IndexOf("(") - 1).Replace(" ", "");

                        }
                        else
                        {
                            homeTeamName = dr["homeTeamName"].ToString();
                            vistortTeamName = dr["vistortTeamName"].ToString();

                        }
                        dttimetemp = Convert.ToDateTime(dr["inTime"].ToString());
                        time = dttimetemp.ToString("yyyy-MM");
                         
                        homeTeamName = homeTeamName.Replace(" ", "");
                        vistortTeamName = vistortTeamName.Replace(" ", "");
                        if (hsteam.ContainsKey(homeTeamName + "-" + vistortTeamName + "-" + time) == false && dr["guessNum"].ToString() != comboBoxEdit3.Text && dr["GameScore"].ToString() != "" && dr["GameScore"].ToString() != "no match")
                        {
                            if (hsscore.Contains(dr["GameScore"]))
                            {
                                j = Convert.ToInt32(hsscore[dr["GameScore"]]);
                                j++;
                                hsscore[dr["GameScore"]] = j;
                                hsdate[dr["GameScore"]] = hsdate[dr["GameScore"]] + dr["guessNum"].ToString() + "-" + dr["league"].ToString();
                            }
                            else
                            {
                                hsscore.Add(dr["GameScore"], 1);
                                hsdate.Add(dr["GameScore"], dr["guessNum"] + "-" + dr["league"]);
                            }
                            


                            hsteam.Add(homeTeamName + "-" + vistortTeamName + "-" + time, 1);
                            hsnum.Add(dr["guessNum"], 1); 
                            hsGameResult.Add(dr["guessNum"], dr["gameReasult"]);
                        }
                        Application.DoEvents();
                        if (hsbqteam.ContainsKey(homeTeamName + "-" + vistortTeamName + "-" + time) == false && dr["guessNum"].ToString() != comboBoxEdit3.Text && dr["bqgameReasult"].ToString() != "" && dr["bqgameReasult"].ToString() != "no match")
                        {
                           
                            if (hsbq.Contains(dr["bqgameReasult"]))
                            {
                                j = Convert.ToInt32(hsbq[dr["bqgameReasult"]]);
                                j++;
                                hsbq[dr["bqgameReasult"]] = j;
                                hsbqdate[dr["bqgameReasult"]] = hsbqdate[dr["bqgameReasult"]] + dr["guessNum"].ToString() + "-" + dr["league"].ToString();
                            }
                            else
                            {
                                hsbq.Add(dr["bqgameReasult"], 1);
                                hsbqdate.Add(dr["bqgameReasult"], dr["guessNum"] + "-" + dr["league"]);
                            }

                            hsbqteam.Add(homeTeamName + "-" + vistortTeamName + "-" + time, 1);
                            hsbqnum.Add(dr["guessNum"], 1);

                        }
                        Application.DoEvents();
                    }
                    ArrayList akeys = new ArrayList(hsscore.Keys);
                    ArrayList keysresult = new ArrayList(hsGameResult.Keys);
                    int index = 0;
                    int imax = 0;
                    int icount = 0;
                    string strnum = "";
                    if (akeys.Count > 1 || akeys.Count == 0)
                    {

                        Application.DoEvents();
                        continue;
                    }
                    strsql1 = "select  * from fb_teamdata where gamedate='"
                            + drall["guessNum"] + "'  and (jxwinper<>'100' or jxdrawper<>'100' or jxloseper<>'100') order by CDate(fb_teamdata.inTime) desc     ";
                    ds = ar.ReturnDataSet(strsql1);
                    if (ds.Tables.Count == 0) continue;
                    dttemp = ds.Tables[0];
                    if (dttemp.Rows.Count == 0) continue;
                    if (dttemp.Rows[0]["jxResult"].ToString() != hsGameResult[keysresult[0]].ToString())
                    {

                        Application.DoEvents();
                        continue;
                    }
                    for (index = 0; index < akeys.Count; )
                    {
                        imax = 0;
                        for (j = 0; j < akeys.Count; j++)
                        {
                            if (strgoal.IndexOf(akeys[j].ToString()) == -1)
                            {
                                icount = Convert.ToInt32(hsscore[akeys[j]]);
                                if (imax < icount)
                                {
                                    imax = icount;
                                    strnum = akeys[j].ToString() + "(" + imax + ")\r\n " + hsdate[akeys[j]].ToString() + "\r\n";

                                }
                            }

                        }

                        if (strgoal == "")
                        {
                            strgoal = strnum;
                        }
                        else
                        {
                            strgoal = strgoal + "," + strnum;

                        }
                        index++;
                    }
                    //if (strgoal != "" && (strgoal.IndexOf(",") == -1 || (homeGoal == "1@2@3@4@" && vistorGoal == "0@1@")))
                    //if (strgoal != "")
                    if (strgoal != "")
                    {
                        if (drall["GameScore"].ToString() != "")
                        {
                            memoEdit1.Text = drall["league"].ToString() + drall["guessNum"].ToString() + "(" + drall["GameScore"] + ")"+ ":" + strgoal + "\r\n" + "homeGoal:" + homeGoal + "\r\n" + "vistorGoal:" + vistorGoal + "\r\n\r\n" + memoEdit1.Text;
                            if (strgoal.IndexOf(drall["GameScore"].ToString()) > -1 && strgoal != "") iright++;
                            iall++;
                        }
                        else
                        {
                            memoEdit1.Text = drall["league"].ToString() + drall["guessNum"].ToString() + ":" + strgoal + "\r\n" + "homeGoal:" + homeGoal + "\r\n" + "vistorGoa:" + vistorGoal + "\r\n\r\n" + memoEdit1.Text;
                            iall++;
                        }

                        Application.DoEvents();
                    }


                    //akeys = new ArrayList(hsbq.Keys);
                    //index = 0;
                    //imax = 0;
                    //icount = 0;
                    //strnum = "";
                    //strgoal = "";
                    //for (index = 0; index < akeys.Count; )
                    //{
                    //    imax = 0;
                    //    for (j = 0; j < akeys.Count; j++)
                    //    {
                    //        if (strgoal.IndexOf(akeys[j].ToString()) == -1)
                    //        {
                    //            icount = Convert.ToInt32(hsbq[akeys[j]]);
                    //            if (imax < icount)
                    //            {
                    //                imax = icount;
                    //                strnum = akeys[j].ToString() + "(" + imax + ")\r\n " + hsbqdate[akeys[j]].ToString() + "\r\n";

                    //            }
                    //        }

                    //    }

                    //    if (strgoal == "")
                    //    {
                    //        strgoal = strnum;
                    //    }
                    //    else
                    //    {
                    //        strgoal = strgoal + "," + strnum;

                    //    }
                    //    index++;
                    //}
                    ////if (strgoal != "" && (strgoal.IndexOf(",") == -1 || (homeGoal == "1@2@3@4@" && vistorGoal == "0@1@")))
                    ////if (strgoal != "")
                    //if (strgoal != "")
                    //{
                    //    if (drall["bqgameReasult"].ToString() != "")
                    //    {
                    //        memoEdit1.Text = drall["league"].ToString() + drall["guessNum"].ToString() + "(" + drall["bqgameReasult"] + ")" + ":" + strgoal + "\r\n" + "homeGoal:" + homeGoal + "\r\n" + "vistorGoal:" + vistorGoal + "\r\n\r\n" + memoEdit1.Text;
                    //        if (strgoal.IndexOf(drall["bqgameReasult"].ToString()) > -1 && strgoal != "") iright++;
                    //        iall++;
                    //    }
                    //    else
                    //    {
                    //        memoEdit1.Text = drall["league"].ToString() + drall["guessNum"].ToString() + ":" + strgoal + "\r\n" + "homeGoal:" + homeGoal + "\r\n" + "vistorGoa:" + vistorGoal + "\r\n\r\n" + memoEdit1.Text;
                    //        iall++;
                    //    }

                    //    Application.DoEvents();
                    //}
                }
                memoEdit1.Text = comboBoxEdit2.Text + ":" + iright + ":" + iall + "\r\n" + "\r\n\r\n" + memoEdit1.Text;
                //iright = 0;
                //iall = 0;
                //foreach (DataRow drall in dtall.Rows)
                //{

                //    if (isbreak) break;
                //    this.Text = "" + drall["guessNum"] + ":" + iright + "(" + iall + ")";
                //    strsql1 = "select  * from fbOddTeamResultView where guessNum='"
                //            + drall["guessNum"] + "' and instr(type,'主队')>0 and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                //    ds = ar.ReturnDataSet(strsql1);
                //    if (ds.Tables.Count == 0) continue;
                //    string strgoal = "";
                //    DataTable dttemp = ds.Tables[0];
                //    if (dttemp.Rows.Count == 0) continue;
                //    Hashtable hsscore = new Hashtable();
                //    Hashtable hsteam = new Hashtable();
                //    Hashtable hsnum = new Hashtable();
                //    Hashtable hsdate = new Hashtable();
                //    homeGoal = dttemp.Rows[0]["homeGoal"].ToString();
                //    vistorGoal = dttemp.Rows[0]["vistorGoal"].ToString();
                //    string homeTeamName = dttemp.Rows[0]["homeTeamName"].ToString().Substring(dttemp.Rows[0]["homeTeamName"].ToString().IndexOf("(") + 1, dttemp.Rows[0]["homeTeamName"].ToString().IndexOf(")") - dttemp.Rows[0]["homeTeamName"].ToString().IndexOf("(") - 1).Replace(" ", "");
                //    string vistortTeamName = dttemp.Rows[0]["vistortTeamName"].ToString().Substring(dttemp.Rows[0]["vistortTeamName"].ToString().IndexOf("(") + 1, dttemp.Rows[0]["vistortTeamName"].ToString().IndexOf(")") - dttemp.Rows[0]["vistortTeamName"].ToString().IndexOf("(") - 1).Replace(" ", "");
                //    string time = dttemp.Rows[0]["fb_gamelist.inTime"].ToString().Substring(0, dttemp.Rows[0]["fb_gamelist.inTime"].ToString().LastIndexOf("-"));
                //    homeTeamName = homeTeamName.Replace(" ", "");
                //    vistortTeamName = vistortTeamName.Replace(" ", "");
                //    if (hsteam.ContainsKey(homeTeamName + "-" + vistortTeamName + "-" + time) == false) hsteam.Add(homeTeamName + "-" + vistortTeamName + "-" + time, 1);
                    
                   
                //    strsql1 = "select  * from fbOddTeamResultView where guessNum='"
                //            + drall["guessNum"] + "' and type='主队上半场' and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                //    ds = ar.ReturnDataSet(strsql1);
                //    if (ds.Tables.Count == 0) continue;
                //    dttemp = ds.Tables[0];
                //    strsql1 = "  abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
                //        + ")<1 and abs(oppGoalVGame-"
                //        + dttemp.Rows[0]["oppGoalVGame"].ToString()
                //        + ")<1 and abs(marginGoal-(" + dttemp.Rows[0]["marginGoal"].ToString() + "))<1    and oddCompany='" + comboBoxEdit4.Text + "' and type='主队上半场' and ((homeGoal='1@0@' and vistorGoal='1@') or (homeGoal='0@1@' and vistorGoal='1@') or (homeGoal='1@' and vistorGoal='0@1@') or (homeGoal='1@2@3@' and vistorGoal='0@1@')  or (homeGoal='0@1@2@3@' and vistorGoal='0@1@')   or (homeGoal='0@1@' and vistorGoal='0@1@2@3@') or (homeGoal='1@' and vistorGoal='1@') or (homeGoal='1@2@' and vistorGoal='1@0@')) ";
                //    strsql2 = "   guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   ) ";
                //    strsql1 = "select * from  fb_gamelist where   " + strsql2 + "    and intime<dateadd('h',-1, cdate('" + drall["intime"] + "')) ";
                //    ds = ar.ReturnDataSet(strsql1);
                //    if (ds.Tables.Count == 0) continue;
                //    dttemp = ds.Tables[0];
                //    if (dttemp.Rows.Count == 0) continue;
                //    strgoal = "";
                //    foreach (DataRow dr in dttemp.Rows)
                //    {
                //        if (strgoal.IndexOf(dr["guessNum"].ToString()) > -1) continue;
                //        if (strgoal == "")
                //            strgoal = "'" + dr["guessNum"].ToString() + "'";
                //        else
                //            strgoal = strgoal + ",'" + dr["guessNum"].ToString() + "'";
                //        Application.DoEvents();
                //    }
                //    strsql1 = "select  * from fbOddTeamResultView where guessNum='"
                //            + drall["guessNum"] + "' and type='主队下半场' and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                //    ds = ar.ReturnDataSet(strsql1);
                //    if (ds.Tables.Count == 0) continue;
                //    dttemp = ds.Tables[0];
                //    strsql1 = "  abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
                //        + ")<1 and abs(oppGoalVGame-"
                //        + dttemp.Rows[0]["oppGoalVGame"].ToString()
                //        + ")<1 and abs(marginGoal-(" + dttemp.Rows[0]["marginGoal"].ToString() + "))<1   and oddCompany='" + comboBoxEdit4.Text + "' and type='主队下半场'  ";

                //    strsql2 = "   guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   ) and  guessNum in (" + strgoal + ")";
                //    strsql1 = "select * from  fb_gamelist where   " + strsql2 + "    and intime<dateadd('h',-1, cdate('" + drall["intime"] + "')) ";
                //    ds = ar.ReturnDataSet(strsql1);
                //    if (ds.Tables.Count == 0) continue;
                //    dttemp = ds.Tables[0];
                //    if (dttemp.Rows.Count == 0) continue;
                //    strgoal = "";
                //    foreach (DataRow dr in dttemp.Rows)
                //    {
                //        if (strgoal.IndexOf(dr["guessNum"].ToString()) > -1) continue;
                //        if (strgoal == "")
                //            strgoal = "'" + dr["guessNum"].ToString() + "'";
                //        else
                //            strgoal = strgoal + ",'" + dr["guessNum"].ToString() + "'";
                //        Application.DoEvents();
                //    }
                //    strsql1 = "select  * from fbOddTeamResultView where guessNum='"
                //            + drall["guessNum"] + "' and type='客队上半场' and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                //    ds = ar.ReturnDataSet(strsql1);
                //    if (ds.Tables.Count == 0) continue;
                //    dttemp = ds.Tables[0];
                //    strsql1 = "  abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
                //        + ")<1 and abs(oppGoalVGame-"
                //        + dttemp.Rows[0]["oppGoalVGame"].ToString()
                //        + ")<1 and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1   and oddCompany='" + comboBoxEdit4.Text + "' and type='客队上半场'  ";

                //    strsql2 = "   guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   ) and  guessNum in (" + strgoal + ")";
                //    strsql1 = "select * from  fb_gamelist where   " + strsql2 + "    and intime<dateadd('h',-1, cdate('" + drall["intime"] + "')) ";
                //    ds = ar.ReturnDataSet(strsql1);
                //    if (ds.Tables.Count == 0) continue;
                //    dttemp = ds.Tables[0];
                //    if (dttemp.Rows.Count == 0) continue;
                //    strgoal = "";
                //    foreach (DataRow dr in dttemp.Rows)
                //    {
                //        if (strgoal.IndexOf(dr["guessNum"].ToString()) > -1) continue;
                //        if (strgoal == "")
                //            strgoal = "'" + dr["guessNum"].ToString() + "'";
                //        else
                //            strgoal = strgoal + ",'" + dr["guessNum"].ToString() + "'";
                //        Application.DoEvents();
                //    }
                //    strsql1 = "select  * from fbOddTeamResultView where guessNum='"
                //            + drall["guessNum"] + "' and type='客队下半场' and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                //    ds = ar.ReturnDataSet(strsql1);
                //    if (ds.Tables.Count == 0) continue;
                //    dttemp = ds.Tables[0];
                //    strsql1 = "  abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
                //        + ")<1 and abs(oppGoalVGame-"
                //        + dttemp.Rows[0]["oppGoalVGame"].ToString()
                //        + ")<1 and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1   and oddCompany='" + comboBoxEdit4.Text + "' and type='客队下半场'  ";

                //    strsql2 = "   guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   ) and  guessNum in (" + strgoal + ")";
                //    strsql1 = "select * from  fb_gamelist where   " + strsql2 + "    and intime<dateadd('h',-1, cdate('" + drall["intime"] + "')) ";
                //    ds = ar.ReturnDataSet(strsql1);
                //    if (ds.Tables.Count == 0) continue;
                //    dttemp = ds.Tables[0];
                //    if (dttemp.Rows.Count == 0) continue;
                //    strgoal = "";
                //    foreach (DataRow dr in dttemp.Rows)
                //    {
                //        homeTeamName = dr["homeTeamName"].ToString().Substring(dr["homeTeamName"].ToString().IndexOf("(") + 1, dr["homeTeamName"].ToString().IndexOf(")") - dr["homeTeamName"].ToString().IndexOf("(") - 1).Replace(" ", "");
                //        vistortTeamName = dr["vistortTeamName"].ToString().Substring(dr["vistortTeamName"].ToString().IndexOf("(") + 1, dr["vistortTeamName"].ToString().IndexOf(")") - dr["vistortTeamName"].ToString().IndexOf("(") - 1).Replace(" ", "");
                //        time = dr["inTime"].ToString().Substring(0, dr["inTime"].ToString().LastIndexOf("-"));
                //        homeTeamName = homeTeamName.Replace(" ", "");
                //        vistortTeamName = vistortTeamName.Replace(" ", "");
                //        if (hsteam.ContainsKey(homeTeamName + "-" + vistortTeamName + "-" + time) == false && dr["guessNum"].ToString() != comboBoxEdit3.Text && dr["GameScore"].ToString() != "" && dr["GameScore"].ToString() != "no match")
                //        {
                //            if (hsscore.Contains(dr["bqgameReasult"]))
                //            {
                //                j = Convert.ToInt32(hsscore[dr["bqgameReasult"]]);
                //                j++;
                //                hsscore[dr["bqgameReasult"]] = j;
                //                hsdate[dr["bqgameReasult"]] = hsdate[dr["bqgameReasult"]] + dr["guessNum"].ToString() + "-" + dr["league"].ToString();
                //            }
                //            else
                //            {
                //                hsscore.Add(dr["bqgameReasult"], 1);
                //                hsdate.Add(dr["bqgameReasult"], dr["guessNum"] + "-" + dr["league"]);
                //            }
                //            hsteam.Add(homeTeamName + "-" + vistortTeamName + "-" + time, 1);
                //            hsnum.Add(dr["guessNum"], 1);
                //        }
                //        Application.DoEvents();
                //    }

                //    ArrayList akeys = new ArrayList(hsscore.Keys);
                //    int index = 0;
                //    int imax = 0;
                //    int icount = 0;
                //    string strnum = "";
                //    for (index = 0; index < akeys.Count; )
                //    {
                //        imax = 0;
                //        for (j = 0; j < akeys.Count; j++)
                //        {
                //            if (strgoal.IndexOf(akeys[j].ToString()) == -1)
                //            {
                //                icount = Convert.ToInt32(hsscore[akeys[j]]);
                //                if (imax < icount)
                //                {
                //                    imax = icount;
                //                    strnum = akeys[j].ToString() + "(" + imax + ")\r\n " + hsdate[akeys[j]].ToString() + "\r\n";

                //                }
                //            }

                //        }

                //        if (strgoal == "")
                //        {
                //            strgoal = strnum;
                //        }
                //        else
                //        {
                //            strgoal = strgoal + "," + strnum;

                //        }
                //        index++;
                //    }
                //    if (strgoal != "")
                //    {
                //        if (drall["bqgameReasult"].ToString() != "")
                //        {
                //            memoEdit1.Text = drall["league"].ToString() + drall["guessNum"].ToString() + "(" + drall["bqgameReasult"] + ")" + ":" + strgoal + "\r\n" + "homeGoal:" + homeGoal + "\r\n" + "vistorGoal:" + vistorGoal + "\r\n\r\n" + memoEdit1.Text;
                //            if (strgoal.IndexOf(drall["bqgameReasult"].ToString()) > -1 && strgoal != "") iright++;
                //            iall++;
                //        }
                //        else
                //        {
                //            memoEdit1.Text = drall["league"].ToString() + drall["guessNum"].ToString() + ":" + strgoal + "\r\n" + "homeGoal:" + homeGoal + "\r\n" + "vistorGoa:" + vistorGoal + "\r\n\r\n" + memoEdit1.Text;
                //            iall++;
                //        }

                //        Application.DoEvents();
                //    }
                //}
                //memoEdit1.Text = comboBoxEdit2.Text + ":" + iright + ":" + iall + "\r\n" + "\r\n\r\n" + memoEdit1.Text;

            
            }
            catch (Exception ex) { memoEdit1.Text = ex.Message + "\r\n" + ex.ToString(); }
            simpleButton4.Text = "....";
            simpleButton4.Enabled = true;
        }



        private void simpleButton6_Click(object sender, EventArgs e)
        {
            isbreak = true;
        }

        private void simpleButton5_Click(object sender, EventArgs e)
        {

            deleTest dele = new deleTest(this.catFun);
            dele.BeginInvoke(null, null);
            //catFun();


        }

        /**
         * 对于日本联赛，如果有SP值低于2的，建议放弃这一场比赛，根据以往的数据，
         * 低于2的赔率打出来的概率很低，对于胜平负赔率都高于2的比赛，
         * 把赔率按照从大到小的顺序分为高中低赔，
         * 规律如下：J联赛：
         * （1）0<=高—中<=0.3 买低赔 正确率90%左右
         * （2）高-中<中-低但不满足（1） 买高赔 正确率90%左右
         * （3） 高-中>中-低  买中赔 正确率85%左右
         *  以上规律适合日本J联赛，不适合J2和日联杯
         *  J2联赛和日联杯：
         *  （1）高-中<中-低且（中-低）-（高-中）在（0,0.25）的范围内，买低赔 正确率90%左右
         *  （2）高-中<中-低 但不满足（1）的第二个条件 买高赔  正确率95%左右
         *  （3）高-中>=中-低 买中赔 正确率95%左右
         *  
         * 
         * 
         * */
        private void simpleButton7_Click(object sender, EventArgs e)
        {
            string strsql1 = "";
            string strsql2 = "";
            DataSet ds = null;
            DataTable dt = null;
            DataTable dtall = null;
            string homeGoal = "";
            string vistorGoal = "";
            string strgoal = "";
            int iright = 0;
            int iall = 0;
            try
            {
                isbreak = false;
                memoEdit1.Text = "";
                strsql2 = " guessNum like'%"
                       + comboBoxEdit2.Text + "%'";
                if (checkEdit7.Checked)
                {
                    strsql2 += " and (GameScore='' or GameScore is null ) ";
                }
                strsql1 = "select  * from  fb_gamelist where  " + strsql2 + "  and (instr(league, '日 职 联')>0 or instr(league , '日 职 乙')>0) ORDER BY guessNum  ";
                ds = ar.ReturnDataSet(strsql1);
                dtall = ds.Tables[0];
                int i = 1, j = 1;
                foreach (DataRow drall in dtall.Rows)
                {

                    if (isbreak) break;
                    //this.Text = "" + drall["guessNum"] + ":" + iright + "(" + iall + ")";
                    string[] stroddli = drall["odd"].ToString().Split(':');
                    if (stroddli.Length == 1) continue;
                    double[] doodli = new double[stroddli.Length];
                    double[] doodOrili = new double[stroddli.Length];
                    strsql1 = "select  * from fbOddTeamResultView where guessNum='"
                            + drall["guessNum"] + "' and type='客队客场' and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) , CDate(fb_oddteamResult.inTime) desc     ";
                    ds = ar.ReturnDataSet(strsql1);
                    DataTable dttemp = ds.Tables[0];
                    homeGoal = dttemp.Rows[0]["homeGoal"].ToString();
                    vistorGoal = dttemp.Rows[0]["vistorGoal"].ToString();
                    for (i = 0; i < stroddli.Length; i++)
                    {
                        doodli[i] = Convert.ToDouble(stroddli[i]);
                        doodOrili[i] = doodli[i];
                    }
                    double dvalue = 0.0;
                    for (i = 0; i < doodli.Length -1; i++)
                        for (j = i + 1; j < doodli.Length; j++)
                        {
                            if (doodli[i] > doodli[j])
                            {
                                dvalue = doodli[i];
                                doodli[i] = doodli[j];
                                doodli[j] = dvalue;
                            }
                        }

                    if (doodli[0] < 2)
                        continue;
                    if (drall["league"].ToString().IndexOf("日 职 联") > -1)
                    {
                        if (0.3 >= doodli[2] - doodli[1] && doodli[2] - doodli[1] >= 0)
                        {
                            if (doodOrili[2] == doodli[0])
                                strgoal = "0";
                            else if (doodOrili[1] == doodli[0])
                                strgoal = "1";
                            else if (doodOrili[0] == doodli[0])
                                strgoal = "3";
                        }
                        else if (doodli[2] - doodli[1] < doodli[1] - doodli[0])
                        {
                            if (doodOrili[2] == doodli[2])
                                strgoal = "0";
                            else if (doodOrili[1] == doodli[2])
                                strgoal = "1";
                            else if (doodOrili[0] == doodli[2])
                                strgoal = "3";
                        }
                        else if (doodli[2] - doodli[1] > doodli[1] - doodli[0])
                        {
                            if (doodOrili[2] == doodli[1])
                                strgoal = "0";
                            else if (doodOrili[1] == doodli[1])
                                strgoal = "1";
                            else if (doodOrili[0] == doodli[1])
                                strgoal = "3";
                        }
                    }
                    else if (drall["league"].ToString().IndexOf("日 职 乙") > -1 || drall["league"].ToString().IndexOf("日 联 杯") > -1)
                    {
                        if (doodli[2] - doodli[1] < doodli[1] - doodli[0]
                            && (doodli[1] - doodli[0]) - (doodli[2] - doodli[1]) < 0.25 && (doodli[1] - doodli[0]) - (doodli[2] - doodli[1]) > 0)
                        {
                            if (doodOrili[2] == doodli[0])
                                strgoal = "0";
                            else if (doodOrili[1] == doodli[0])
                                strgoal = "1";
                            else if (doodOrili[0] == doodli[0])
                                strgoal = "3";
                        }
                        else if (doodli[2] - doodli[1] < doodli[1] - doodli[0])
                        {
                            if (doodOrili[2] == doodli[2])
                                strgoal = "0";
                            else if (doodOrili[1] == doodli[2])
                                strgoal = "1";
                            else if (doodOrili[0] == doodli[2])
                                strgoal = "3";
                        }
                        else if (doodli[2] - doodli[1] >= doodli[1] - doodli[0])
                        {
                            if (doodOrili[2] == doodli[1])
                                strgoal = "0";
                            else if (doodOrili[1] == doodli[1])
                                strgoal = "1";
                            else if (doodOrili[0] == doodli[1])
                                strgoal = "3";
                        }

                    }
                    memoEdit1.Text = drall["guessNum"].ToString() + "(" + drall["GameScore"] + ")" + ":" + strgoal + "\r\n" + "homeGoal:" + homeGoal + "\r\n" + "vistorGoal" + vistorGoal + "\r\n\r\n" + memoEdit1.Text;

                    Application.DoEvents();

                }


            }
            catch (Exception ex) { memoEdit1.Text = ex.Message; }
            simpleButton4.Text = "....";
            simpleButton4.Enabled = true;
        }

        private void simpleButton8_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("是否确认清楚非必须数据？", "清除确认", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                string strsql1 = "";
                string strsql2 = "";
                DataSet ds = null;
                DataSet dsdate = null;
                DataTable dtdateall = null;
                DataTable dt = null;
                DataTable dtall = null;
                string homeGoal = "";
                string vistorGoal = "";
                int iright = 0;
                long iall = 0;
                try
                {
                    isbreak = false;
                    simpleButton8.Enabled = false;
                    dsdate = ar.ReturnDataSet("select  distinct  top " + comboBoxEdit5.Text + " gameDate from fb_gamelist where guessType='" + comboBoxEdit1.Text + "' and gameReasult<>''  and gameReasult is not null and intime>(select top 1 intime from fb_gamelist where gameDate like '%" + comboBoxEdit7.Text + "%' ) order by gameDate  " + comboBoxEdit6.Text);

                    dtdateall = dsdate.Tables[0];
                    foreach (DataRow dtdate in dtdateall.Rows)
                    {
                        if (isbreak) break;
                        strsql2 = " guessNum like'%"
                               + dtdate["gameDate"] + "%'";
                        if (checkEdit7.Checked)
                        {
                            strsql2 += " and  (GameScore='' or GameScore is null )  ";
                        }
                        else
                        {
                            strsql2 += " and  1=1 ";
                        }
                        this.Text = dtdate["gameDate"].ToString() + " 0:" + iall.ToString();
                        strsql1 = "select  * from  fb_gamelist where  " + strsql2 + " ORDER BY guessNum  ";
                        dsdate = ar.ReturnDataSet(strsql1);
                        dtall = dsdate.Tables[0];
                        if (dsdate.Tables.Count == 0) continue;
                        foreach (DataRow drall in dtall.Rows)
                        {
                            this.Text = drall["guessNum"].ToString() + " " + iright.ToString() + ":" + iall.ToString();
                            strsql2 = " gamedate ='"
                               + drall["guessNum"] + "'";
                            strsql2 += " and  1=1 ";
                            strsql1 = "select  * from  fb_teamdata where  " + strsql2 + " ORDER BY inTime  ";
                            ds = ar.ReturnDataSet(strsql1);
                            DataTable dttemp = ds.Tables[0];
                            if (dttemp.Rows.Count == 0)
                            {
                                Application.DoEvents();
                                continue;
                            }
                            DateTime dttime = Convert.ToDateTime(dttemp.Rows[0]["inTime"].ToString());
                            string strnewtime = dttime.AddMinutes(10).ToString("yyyy-MM-dd HH:mm:ss");

                            dttime = Convert.ToDateTime(dttemp.Rows[dttemp.Rows.Count - 1]["inTime"].ToString());
                            string strnewtime2 = dttime.AddMinutes(-10).ToString("yyyy-MM-dd HH:mm:ss");
                            strsql2 = "delete * from fb_teamdata where inTime>cdate('" + strnewtime + "') and inTime<cdate('" + strnewtime2 + "') and gamedate='" + drall["guessNum"] + "'";

                            //if (dttemp.Rows.Count > 6)
                            //{
                            //    strsql2 = "delete * from fb_teamdata where inTime<cdate('" + strnewtime2 + "') and gamedate='" + drall["guessNum"] + "'";
                            iright = ar.ExeSQL(strsql2);
                            iall += iright;
                            //}

                            strsql2 = " gameID ='"
                               + drall["guessNum"] + "'";
                            strsql2 += " and  1=1 ";
                            strsql1 = "select  * from  fb_oddteamResult where  oddCompany='澳门' and  " + strsql2 + " ORDER BY inTime  ";
                            ds = ar.ReturnDataSet(strsql1);
                            dttemp = ds.Tables[0];
                            if (dttemp.Rows.Count == 0)
                            {
                                Application.DoEvents();
                                continue;
                            }
                            dttime = Convert.ToDateTime(dttemp.Rows[dttemp.Rows.Count - 1]["inTime"].ToString());
                            strnewtime = dttime.AddMinutes(-10).ToString("yyyy-MM-dd HH:mm:ss");


                            strsql2 = "delete * from fb_oddteamResult where inTime<cdate('" + strnewtime + "')  and gameID='" + drall["guessNum"] + "'";
                            //strsql2 = "delete * from fb_teamdata where inTime>cdate('" + strnewtime + "') and gamedate='" + drall["guessNum"] + "'";
                            if (dttemp.Rows.Count > 1)
                            {
                                iright = ar.ExeSQL(strsql2);
                                iall += iright;
                            }
                            Application.DoEvents();
                        }
                    }
                }
                catch (Exception ex) { memoEdit1.Text = ex.Message; }
                simpleButton8.Enabled = true;

            }
        }

        private void simpleButton9_Click(object sender, EventArgs e)
        {
            //DataSet ds = null;
            //DataTable dt = null;
            //DataTable dtall = null;
            //int i=0;
            //if (memoEdit1.Text == "" || (memoEdit1.Text.Trim()) == "")
            //{
            //    return;
            //}
            //string strsql1 = "select * from  fb_gamelist where  guessNum like '" + comboBoxEdit2.Text + "%' ORDER BY guessNum  ";
            //DataSet dsdate = ar.ReturnDataSet(strsql1);

            //dtall = dsdate.Tables[0];
            
            //string[] sArray = Regex.Split(memoEdit1.Text, "\r\n", RegexOptions.IgnoreCase);
            //foreach (DataRow dtdate in dtall.Rows)
            //{
            //    if (i >= sArray.Length) break;
            //    strsql1 = "update  fb_gamelist  set   bqgameReasult='" + sArray[i].Replace("-","")  + "' where guessNum='" + dtdate["guessNum"] + "'";
            //    ar.ExeSQL(strsql1);
            //    i++;
            //}
            //memoEdit1.Text = "";
            /*
            string strsql1 = "";
            string strsql2 = "";
            DataSet ds = null;
            DataSet dsdate = null;
            DataTable dtdateall = null;
            DataTable dt = null;
            DataTable dtall = null;
            string homeGoal = "";
            string vistorGoal = "";
            int iright = 0;
            long iall = 0;
            int addball = 0;
            try
            {
                isbreak = false;
                simpleButton9.Enabled = false;
                dsdate = ar.ReturnDataSet("select    gameID AS  gameDate       from fb_oddteamResult where    inTime<cdate('2012-12-13 23:59:59') ORDER BY gameID desc");

                dtdateall = dsdate.Tables[0];
                foreach (DataRow dtdate in dtdateall.Rows)
                {
                    if (isbreak) break;
                    strsql2 = " guessNum ='"
                           + dtdate["gameDate"] + "'";
                    //if (checkEdit7.Checked)
                    {
                        //strsql2 += " and  (GameScore<>'' or GameScore is not null )  ";
                    }
                    //else
                    //{
                    //    strsql2 += " and  1=1 ";
                    //}
                    this.Text = dtdate["gameDate"].ToString() + " 0:" + iall.ToString();
                    strsql1 = "select  * from  fb_gamelist where  " + strsql2 + " ORDER BY guessNum  ";
                    dsdate = ar.ReturnDataSet(strsql1);
                    dtall = dsdate.Tables[0];
                    if (dsdate.Tables.Count == 0) continue;
                    if (dtall.Rows.Count == 0)
                    {
                        Application.DoEvents();
                        strsql2 = "delete * from fb_oddteamResult where gameID='" + dtdate["gameDate"] + "'";
                        iright = ar.ExeSQL(strsql2);
                        iall += iright;
                        Application.DoEvents();
                        this.Text = dtdate["gameDate"].ToString() + " 0:" + iall.ToString();
                        continue;
                    }
                    if (dtall.Rows[0]["GameScore"].ToString()=="")
                    {
                        Application.DoEvents();
                        this.Text = dtdate["gameDate"].ToString() + " 0:" + iall.ToString();
                        continue;

                    }
                    foreach (DataRow drall in dtall.Rows)
                    {
                        this.Text = drall["guessNum"].ToString() + " " + iright.ToString() + ":" + iall.ToString();
                        if (drall["addPoint"].ToString()!="")
                        {
                            addball = Convert.ToInt32(drall["addPoint"].ToString());
                        }
                        else
                        {
                            addball = 0;
                        }
                        strsql2 = " gameID ='"
                           + drall["guessNum"] + "'";
                        strsql2 += " and  1=1 ";
                        strsql1 = "select  * from  fb_oddteamResult where  " + strsql2 + " ORDER BY inTime  ";
                        ds = ar.ReturnDataSet(strsql1);
                        DataTable dttemp = ds.Tables[0];
                        if (dttemp.Rows.Count == 0)
                        {
                            Application.DoEvents();
                            continue;
                        }
                        for (int i = 0; i < dttemp.Rows.Count;i++ )
                        {
                            homeGoal = dttemp.Rows[i]["homeGoal"].ToString();
                            vistorGoal=dttemp.Rows[i]["vistorGoal"].ToString();
                            string[] strh=homeGoal.Split('@');
                            string[] strv = vistorGoal.Split('@');
                            string gameresult = "";
                            for (int m=0;m<strh.Length-1;m++)
                            {
                                for (int n = 0; n < strv.Length-1; n++)
                                {
                                    if (addball + Convert.ToInt32(strh[m]) > Convert.ToInt32(strv[n]))
                                    {
                                        if (gameresult.IndexOf("3")==-1) gameresult += "3";
                                    }
                                    else if (addball + Convert.ToInt32(strh[m]) == Convert.ToInt32(strv[n]))
                                    {
                                        if (gameresult.IndexOf("1") == -1) gameresult += "1";
                                    }
                                    else
                                    {
                                        if (gameresult.IndexOf("0") == -1) gameresult += "0";
                                    }

                                }
                            }
                            strsql2 = "update  fb_oddteamResult set gameResult='" + gameresult + "',inTime=CDATE('2012-12-13 23:59:59') where ID='{" + dttemp.Rows[i]["ID"].ToString() + "}'";
                            iright = ar.ExeSQL(strsql2);
                            Application.DoEvents();
                            iall += iright;
                        }
                        //if (dttemp.Rows.Count > 6)
                        //{
                        //    strsql2 = "delete * from fb_teamdata where inTime<cdate('" + strnewtime2 + "') and gamedate='" + drall["guessNum"] + "'";
                       
                        //}

                        //strsql2 = " gameID ='"
                        //   + drall["guessNum"] + "'";
                        //strsql2 += " and  1=1 ";
                        //strsql1 = "select  * from  fb_oddteamResult where  oddCompany='澳门' and  " + strsql2 + " ORDER BY inTime  ";
                        //ds = ar.ReturnDataSet(strsql1);
                        //dttemp = ds.Tables[0];
                        //if (dttemp.Rows.Count == 0)
                        //{
                        //    Application.DoEvents();
                        //    continue;
                        //}
                        ////strsql2 = "delete * from fb_teamdata where inTime>cdate('" + strnewtime + "') and gamedate='" + drall["guessNum"] + "'";
                        //if (dttemp.Rows.Count > 1)
                        //{
                        //    iright = ar.ExeSQL(strsql2);
                        //    iall += iright;
                        //}
                        Application.DoEvents();
                    }
                }
            }
            catch (Exception ex) { memoEdit1.Text = ex.Message; }
            simpleButton9.Enabled = true;

            */
            /*
            string strsql1 = "";
            string strsql2 = "";
            DataSet ds = null;
            DataSet dsdate = null;
            DataTable dtdateall = null;
            DataTable dt = null;
            DataTable dtall = null;
            string homeGoal = "";
            string vistorGoal = "";
            int iright = 0;
            long iall = 0;
            int addball = 0;
            try
            {
                isbreak = false;
                simpleButton9.Enabled = false;
                dsdate = ar.ReturnDataSet("select    gameID AS  gameDate       from fb_oddteamResult where    inTime<cdate('2013-02-24 23:58:58') ORDER BY gameID desc");

                dtdateall = dsdate.Tables[0];
                foreach (DataRow dtdate in dtdateall.Rows)
                {
                    if (isbreak) break;
                    strsql2 = " guessNum ='"
                           + dtdate["gameDate"] + "'";
                    //if (checkEdit7.Checked)
                    {
                        //strsql2 += " and  (GameScore<>'' or GameScore is not null )  ";
                    }
                    //else
                    //{
                    //    strsql2 += " and  1=1 ";
                    //}
                    this.Text = dtdate["gameDate"].ToString() + " 0:" + iall.ToString();
                    strsql1 = "select  * from  fb_gamelist where  " + strsql2 + " ORDER BY guessNum  ";
                    dsdate = ar.ReturnDataSet(strsql1);
                    dtall = dsdate.Tables[0];
                    int ilow=-1;
                    if (dsdate.Tables.Count == 0) continue;
                    if (dtall.Rows.Count == 0)
                    {
                        Application.DoEvents();
                        strsql2 = "delete * from fb_oddteamResult where gameID='" + dtdate["gameDate"] + "'";
                        iright = ar.ExeSQL(strsql2);
                        iall += iright;
                        Application.DoEvents();
                        this.Text = dtdate["gameDate"].ToString() + " 0:" + iall.ToString();
                        continue;
                    }
                    if (dtall.Rows[0]["GameScore"].ToString() == "")
                    {
                        Application.DoEvents();
                        this.Text = dtdate["gameDate"].ToString() + " 0:" + iall.ToString();
                        continue;

                    }
                    if (dtall.Rows[0]["odd"].ToString() == "err")
                    {
                        continue;
                    }
                    string[] strodds = dtall.Rows[0]["odd"].ToString().Split(':');
                    if (Convert.ToDouble(strodds[0]) < Convert.ToDouble(strodds[2]))
                    {
                        ilow=0;
                    }
                    else if (Convert.ToDouble(strodds[0])> Convert.ToDouble(strodds[2]))
                    {
                        ilow=1;
                    }
                    else
                    {
                        continue;
                    }
                    foreach (DataRow drall in dtall.Rows)
                    {
                        this.Text = drall["guessNum"].ToString() + " " + iright.ToString() + ":" + iall.ToString();
                        
                        strsql2 = " gameID ='"
                           + drall["guessNum"] + "'";
                        strsql2 += " and  1=1 ";
                        strsql1 = "select  * from  fb_oddteamResult where  " + strsql2 + " and inTime<CDATE('2013-02-24 23:58:58') ORDER BY inTime  ";
                        ds = ar.ReturnDataSet(strsql1);
                        DataTable dttemp = ds.Tables[0];
                        if (dttemp.Rows.Count == 0)
                        {
                            Application.DoEvents();
                            continue;
                        }
                        for (int i = 0; i < dttemp.Rows.Count; i++)
                        {
                            homeGoal = dttemp.Rows[i]["homeGoal"].ToString();
                            vistorGoal = dttemp.Rows[i]["vistorGoal"].ToString();
                            string[] strh = homeGoal.Split('@');
                            string[] strv = vistorGoal.Split('@');
                            string gameresult = "";
                            if (ilow==0)
                            {
                                
                                    for (int m = 0; m < strh.Length - 1; m++)
                                    {
                                        gameresult += (Convert.ToInt32(strh[m]) + 1).ToString()+"@";
                                    }
                                    strsql2 = "update  fb_oddteamResult set homeGoal='" + gameresult + "',inTime=CDATE('2013-02-24 23:58:58') where ID='{" + dttemp.Rows[i]["ID"].ToString() + "}'";
                                    iright = ar.ExeSQL(strsql2);
                            }
                            else if (ilow == 1)
                            {
                                for (int m = 0; m < strv.Length - 1; m++)
                                {
                                    gameresult += (Convert.ToInt32(strv[m]) + 1).ToString() + "@";
                                }
                                strsql2 = "update  fb_oddteamResult set vistorGoal='" + gameresult + "',inTime=CDATE('2013-02-24 23:58:58') where ID='{" + dttemp.Rows[i]["ID"].ToString() + "}'";
                                iright = ar.ExeSQL(strsql2);
                            }
                            
                           
                            Application.DoEvents();
                            iall += iright;
                        }
                        
                        Application.DoEvents();
                    }
                }
            }
            catch (Exception ex) { memoEdit1.Text = ex.Message; }
            simpleButton9.Enabled = true;
            */
        }

        private void simpleButton10_Click(object sender, EventArgs e)
        {
            string strsql1 = "";
            string strsql2 = "";
            DataSet ds = null;
            DataSet dsdate = null;
            DataTable dtdateall = null;
            DataTable dt = null;
            DataTable dtall = null;
            string homeGoal = "";
            string vistorGoal = "";
            int iright = 0;
            long iall = 0;
            try
            {
                isbreak = false;
                simpleButton10.Enabled = false;
                dsdate = ar.ReturnDataSet("select  distinct  top " + comboBoxEdit5.Text + " gameDate from fb_gamelist where guessType='" + comboBoxEdit1.Text + "' and gameReasult<>'' and gameDate='" + comboBoxEdit2.Text + "'  and gameReasult is not null and intime>(select top 1 intime from fb_gamelist where gameDate like '%" + comboBoxEdit7.Text + "%' ) order by gameDate  " + comboBoxEdit6.Text);
                
                dtdateall = dsdate.Tables[0];
                foreach (DataRow dtdate in dtdateall.Rows)
                {
                    if (isbreak) break;
                    this.Text = dtdate["gameDate"].ToString() + " 0:" + iall.ToString();
                    strsql2 = " guessNum like'%"
                           + dtdate["gameDate"] + "%'";
                    if (checkEdit7.Checked)
                    {
                        strsql2 += " and  (GameScore='' or GameScore is null )  ";
                    }
                    else
                    {
                        strsql2 += " and  1=1 ";
                    }
                    this.Text = dtdate["gameDate"].ToString() + " 0:" + iall.ToString();
                    strsql1 = "select  * from  fb_gamelist where  " + strsql2 + " ORDER BY guessNum  ";
                    dsdate = ar.ReturnDataSet(strsql1);
                    dtall = dsdate.Tables[0];
                    if (dsdate.Tables.Count == 0) continue;
                    foreach (DataRow drall in dtall.Rows)
                    {
                        
                        strsql2 = " gamedate ='"
                           + drall["guessNum"] + "'";
                        strsql2 += " and  1=1 ";
                        strsql1 = "select  * from  fb_teamdata where  " + strsql2 + " ORDER BY inTime  ";
                        ds = ar.ReturnDataSet(strsql1);
                        DataTable dttemp = ds.Tables[0];
                        if (dttemp.Rows.Count == 0)
                        {
                            Application.DoEvents();
                            continue;
                        }
                        string stremp = "";
                        foreach (DataRow dr in dttemp.Rows)
                        {

                            strsql2 = "delete * from fb_teamdata where  gamedate='" + dr["gameDate"] + "'  and jxwinper='" + dr["jxwinper"] + "' and jxdrawper='" + dr["jxdrawper"] + "' and jxloseper='" + dr["jxloseper"] + "' and ID<>'{" + dr["ID"] + "}' ";
                            if (stremp.IndexOf("gamedate='" + dr["gameDate"] + "'  and jxwinper='" + dr["jxwinper"] + "' and jxdrawper='" + dr["jxdrawper"] + "' and jxloseper='" + dr["jxloseper"] + "'") > -1)
                            {
                                Application.DoEvents();
                                continue;
                            }
                            if ("" == stremp)
                            {
                                stremp = "gamedate='" + dr["gameDate"] + "'  and jxwinper='" + dr["jxwinper"] + "' and jxdrawper='" + dr["jxdrawper"] + "' and jxloseper='" + dr["jxloseper"] + "'";
                            }
                            else
                            {
                                stremp = stremp + " gamedate='" + dr["gameDate"] + "'  and jxwinper='" + dr["jxwinper"] + "' and jxdrawper='" + dr["jxdrawper"] + "' and jxloseper='" + dr["jxloseper"] + "'";
                            }
                            //if (dttemp.Rows.Count > 6)
                            //{
                            //    strsql2 = "delete * from fb_teamdata where inTime<cdate('" + strnewtime2 + "') and gamedate='" + drall["guessNum"] + "'";
                            iright = ar.ExeSQL(strsql2);
                            if(iright<0)iright=0;
                            iall += iright;
                            //}

                            this.Text = dtdate["gameDate"].ToString() + " 0:" + iall.ToString();
                            Application.DoEvents();
                        }
                    }
                    this.Text = dtdate["gameDate"].ToString() + " 0:" + iall.ToString();
                }
            }
            catch (Exception ex) { memoEdit1.Text = ex.Message; }
            simpleButton10.Enabled = true;
        }

       
        //private void simpleButton5_Click(object sender, EventArgs e)
        //{
        //    simpleButton5.Text = "。。。";
        //    simpleButton5.Enabled = false;
        //    string strsql1 = "";
        //    string strsql2 = "";
        //    DataSet ds = null;
        //    DataSet dsdate = null;
        //    DataTable dtdateall = null;
        //    DataTable dt = null;
        //    DataTable dtall = null;
        //    string homeGoal = "";
        //    string vistorGoal = "";
        //    int iright = 0;
        //    int iall = 0;
        //    try
        //    {
        //        isbreak = false; ;
        //        memoEdit1.Text = "";
        //        if (checkEdit7.Checked==false)
        //            dsdate = ar.ReturnDataSet("select  distinct top 10 gameDate from fb_gamelist where guessType='" + comboBoxEdit1.Text + "' order by gameDate desc ");
        //        else
        //        dsdate = ar.ReturnDataSet("select distinct gameDate from fb_gamelist where gameDate='" + comboBoxEdit2.Text + "' order by gameDate desc ");
        //        dtdateall = dsdate.Tables[0];
        //        foreach (DataRow dtdate in dtdateall.Rows)
        //        {
        //            if (isbreak) break;
        //            strsql2 = " guessNum like'%"
        //                   + dtdate["gameDate"] + "%'";
        //            if (checkEdit7.Checked)
        //            {
        //                strsql2 += " and GameScore='' ";
        //            }
        //            else
        //            {
        //                strsql2 += " and GameScore<>'' ";
        //            }

        //            strsql1 = "select  * from  fb_gamelist where  " + strsql2 + " ORDER BY guessNum  ";
        //            dsdate = ar.ReturnDataSet(strsql1);
        //            dtall = dsdate.Tables[0];
        //            int i = 1, j = 1;
        //            iright = 0;
        //            iall = 0;
        //            foreach (DataRow drall in dtall.Rows)
        //            {
        //                if (isbreak) break;
        //                this.Text = "" + drall["guessNum"] + ":" + iright + "(" + iall+")";
        //                strsql1 = "select  * from fbOddTeamResultView where guessNum='"
        //                        + drall["guessNum"] + "' and instr(type,'主队')>0 and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) desc, CDate(fb_oddteamResult.inTime) desc     ";
        //                ds = ar.ReturnDataSet(strsql1);
        //                DataTable dttemp = ds.Tables[0];
        //                if (dttemp.Rows.Count == 0) continue;
        //                Hashtable hsscore = new Hashtable();
        //                Hashtable hsteam = new Hashtable();
        //                Hashtable hsnum = new Hashtable();
        //                double goalmax = 0, goalmin = 99999, goalvmax = 0,goalvmin = 99999, goalmarmax = 0, goalmarmin = 99999;
        //                if (dttemp.Rows.Count > 0)
        //                {
        //                    foreach (DataRow drtemp in dttemp.Rows)
        //                    {
        //                        if (isbreak) break;
        //                        if(drtemp["type"].ToString().IndexOf("半场")>-1) continue ;
        //                        if (Convert.ToDouble(drtemp["goalVGame"].ToString()) > goalmax)
        //                        {
        //                            goalmax = Convert.ToDouble(drtemp["goalVGame"].ToString());
        //                        }
        //                        if (goalmin > Convert.ToDouble(drtemp["goalVGame"].ToString()))
        //                        {
        //                            goalmin = Convert.ToDouble(drtemp["goalVGame"].ToString());
        //                        }

        //                        if (Convert.ToDouble(drtemp["oppGoalVGame"].ToString()) > goalvmax)
        //                        {
        //                            goalvmax = Convert.ToDouble(drtemp["oppGoalVGame"].ToString());
        //                        }
        //                        if (goalvmin > Convert.ToDouble(drtemp["oppGoalVGame"].ToString()))
        //                        {
        //                            goalvmin = Convert.ToDouble(drtemp["oppGoalVGame"].ToString());
        //                        }

        //                        //if (drtemp["type"].ToString().IndexOf("近六轮") > -1) continue;
        //                        if (Convert.ToDouble(drtemp["marginGoal"].ToString()) > goalmarmax)
        //                        {
        //                            goalmarmax = Convert.ToDouble(drtemp["marginGoal"].ToString());
        //                        }
        //                        if (goalmarmin > Convert.ToDouble(drtemp["marginGoal"].ToString()))
        //                        {
        //                            goalmarmin = Convert.ToDouble(drtemp["marginGoal"].ToString());
        //                        }
        //                    }


        //                }

        //                homeGoal = dttemp.Rows[0]["homeGoal"].ToString();
        //                vistorGoal = dttemp.Rows[0]["vistorGoal"].ToString();
        //                string homeTeamName = dttemp.Rows[0]["homeTeamName"].ToString().Substring(dttemp.Rows[0]["homeTeamName"].ToString().IndexOf("(") + 1, dttemp.Rows[0]["homeTeamName"].ToString().IndexOf(")") - dttemp.Rows[0]["homeTeamName"].ToString().IndexOf("(") - 1).Replace(" ", "");
        //                string vistortTeamName = dttemp.Rows[0]["vistortTeamName"].ToString().Substring(dttemp.Rows[0]["vistortTeamName"].ToString().IndexOf("(") + 1, dttemp.Rows[0]["vistortTeamName"].ToString().IndexOf(")") - dttemp.Rows[0]["vistortTeamName"].ToString().IndexOf("(") - 1).Replace(" ", "");
        //                string time = dttemp.Rows[0]["fb_gamelist.inTime"].ToString().Substring(0, dttemp.Rows[0]["fb_gamelist.inTime"].ToString().LastIndexOf("-"));
        //                if (hsteam.ContainsKey(homeTeamName + "-" + vistortTeamName + "-" + time) == false) hsteam.Add(homeTeamName + "-" + vistortTeamName + "-" + time, 1);
        //                //strsql1 = "abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
        //                //        + ")<1 and abs(oppGoalVGame-"
        //                //        + dttemp.Rows[0]["oppGoalVGame"].ToString()
        //                //        + ")<1 and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1   and oddCompany='" + comboBoxEdit4.Text + "' and type='主队近六轮' and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";
        //                strsql1 = (goalmax + 1) + " >=CDBL(goalVGame) and CDBL(goalVGame)>=" + (goalmin - 1) + " and "
        //                   + (goalvmax + 1) + ">=CDBL(oppGoalVGame) and CDBL(oppGoalVGame)>=" + (goalvmin - 1)
        //                   + " and "
        //                   + (goalmarmax + 1) + ">=CDBL(marginGoal) and CDBL(marginGoal)>=" + (goalmarmin - 1) + "    and oddCompany='" + comboBoxEdit4.Text + "'  and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";

        //                strsql2 = "   guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   )";
        //                strsql1 = "select * from  fb_gamelist where guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql2 + "   )";
        //                ds = ar.ReturnDataSet(strsql1);
        //                dttemp = ds.Tables[0];
        //                if (dttemp.Rows.Count == 0) continue;
        //                string strgoal = "";
        //                foreach (DataRow dr in dttemp.Rows)
        //                {
        //                    if (strgoal.IndexOf(dr["guessNum"].ToString()) > -1) continue;
        //                    if (strgoal == "")
        //                        strgoal = "'" + dr["guessNum"].ToString() + "'";
        //                    else
        //                        strgoal = strgoal + ",'" + dr["guessNum"].ToString() + "'";
        //                    Application.DoEvents();
        //                }
        //                strsql1 = "select  * from fbOddTeamResultView where guessNum='"
        //                        + drall["guessNum"] + "' and instr(type,'客队')>0  and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) desc, CDate(fb_oddteamResult.inTime) desc     ";
        //                ds = ar.ReturnDataSet(strsql1);
        //                dttemp = ds.Tables[0];
        //                goalmax = 0;
        //                goalmin = 99999; 
        //                goalvmax = 0;
        //                goalvmin = 99999;
        //                goalmarmax = 0;
        //                goalmarmin = 99999;
        //                if (dttemp.Rows.Count > 0)
        //                {
        //                    foreach (DataRow drtemp in dttemp.Rows)
        //                    {
        //                        if (isbreak) break;
        //                        if(drtemp["type"].ToString().IndexOf("半场")>-1) continue ;
        //                        if (Convert.ToDouble(drtemp["goalVGame"].ToString()) > goalmax)
        //                        {
        //                            goalmax = Convert.ToDouble(drtemp["goalVGame"].ToString());
        //                        }
        //                        if (goalmin > Convert.ToDouble(drtemp["goalVGame"].ToString()))
        //                        {
        //                            goalmin = Convert.ToDouble(drtemp["goalVGame"].ToString());
        //                        }

        //                        if (Convert.ToDouble(drtemp["oppGoalVGame"].ToString()) > goalvmax)
        //                        {
        //                            goalvmax = Convert.ToDouble(drtemp["oppGoalVGame"].ToString());
        //                        }
        //                        if (goalvmin > Convert.ToDouble(drtemp["oppGoalVGame"].ToString()))
        //                        {
        //                            goalvmin = Convert.ToDouble(drtemp["oppGoalVGame"].ToString());
        //                        }
        //                        //if (drtemp["type"].ToString().IndexOf("近六轮") > -1) continue;
        //                        if (Convert.ToDouble(drtemp["marginGoal"].ToString()) > goalmarmax)
        //                        {
        //                            goalmarmax = Convert.ToDouble(drtemp["marginGoal"].ToString());
        //                        }
        //                        if (goalmarmin > Convert.ToDouble(drtemp["marginGoal"].ToString()))
        //                        {
        //                            goalmarmin = Convert.ToDouble(drtemp["marginGoal"].ToString());
        //                        }
        //                    }


        //                }
        //                //strsql1 = "abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
        //                //        + ")<1 and abs(oppGoalVGame-"
        //                //        + dttemp.Rows[0]["oppGoalVGame"].ToString()lastrankings
        //                //        + ")<1 and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1  and oddCompany='" + comboBoxEdit4.Text + "' and type='客队近六轮' and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";
        //                //strsql1 = "  abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
        //                //    + ")<1 and abs(oppGoalVGame-"
        //                //    + dttemp.Rows[0]["oppGoalVGame"].ToString()
        //                //    + ")<1 and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1    and oddCompany='" + comboBoxEdit4.Text + "' and type='客队全局' and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";
        //                strsql1 = (goalmax + 1) + " >=CDBL(goalVGame) and CDBL(goalVGame)>=" + (goalmin - 1) + " and "
        //                   + (goalvmax + 1) + ">=CDBL(oppGoalVGame) and CDBL(oppGoalVGame)>=" + (goalvmin - 1)
        //                   + " and "
        //                   + (goalmarmax + 1) + ">=CDBL(marginGoal) and CDBL(marginGoal)>=" + (goalmarmin -1) + "    and oddCompany='" + comboBoxEdit4.Text + "'  and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";

        //                strsql2 = "   guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   ) and  guessNum in (" + strgoal + ")";
        //                strsql1 = "select * from  fb_gamelist where   " + strsql2 + "   ";
        //                ds = ar.ReturnDataSet(strsql1);
        //                dttemp = ds.Tables[0];
        //                if (dttemp.Rows.Count == 0) continue;
        //                strgoal = "";
        //                foreach (DataRow dr in dttemp.Rows)
        //                {
        //                    if (strgoal.IndexOf(dr["guessNum"].ToString()) > -1) continue;
        //                    if (strgoal == "")
        //                        strgoal = "'" + dr["guessNum"].ToString() + "'";
        //                    else
        //                        strgoal = strgoal + ",'" + dr["guessNum"].ToString() + "'";
        //                    Application.DoEvents();
        //                }
        //                strsql1 = "select  * from fbOddTeamResultView where guessNum='"
        //                        + drall["guessNum"] + "' and type='主队主场' and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) desc, CDate(fb_oddteamResult.inTime) desc     ";
        //                ds = ar.ReturnDataSet(strsql1);
        //                dttemp = ds.Tables[0];
        //                //strsql1 = "abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
        //                //        + ")<1 and abs(oppGoalVGame-"
        //                //        + dttemp.Rows[0]["oppGoalVGame"].ToString()lastrankings
        //                //        + ")<1 and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1  and oddCompany='" + comboBoxEdit4.Text + "' and type='主队近六轮' and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";
        //                strsql1 = "  abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
        //                    + ")<1.14 and abs(oppGoalVGame-"
        //                    + dttemp.Rows[0]["oppGoalVGame"].ToString()
        //                    + ")<1.1 and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1    and oddCompany='" + comboBoxEdit4.Text + "' and type='主队主场' and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";

        //                strsql2 = "   guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   ) and  guessNum in (" + strgoal + ")";
        //                strsql1 = "select * from  fb_gamelist where   " + strsql2 + "   ";
        //                ds = ar.ReturnDataSet(strsql1);
        //                dttemp = ds.Tables[0];
        //                if (dttemp.Rows.Count == 0) continue;
        //                strgoal = "";
        //                foreach (DataRow dr in dttemp.Rows)
        //                {
        //                    if (strgoal.IndexOf(dr["guessNum"].ToString()) > -1) continue;
        //                    if (strgoal == "")
        //                        strgoal = "'" + dr["guessNum"].ToString() + "'";
        //                    else
        //                        strgoal = strgoal + ",'" + dr["guessNum"].ToString() + "'";
        //                    Application.DoEvents();
        //                }
        //                strsql1 = "select  * from fbOddTeamResultView where guessNum='"
        //                        + drall["guessNum"] + "' and type='客队客场' and oddCompany='" + comboBoxEdit4.Text + "'  order by fb_gamelist.guessNum, CDate(fb_teamdata.inTime) desc, CDate(fb_oddteamResult.inTime) desc     ";
        //                ds = ar.ReturnDataSet(strsql1);
        //                dttemp = ds.Tables[0];
        //                //strsql1 = "abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
        //                //        + ")<1 and abs(oppGoalVGame-"
        //                //        + dttemp.Rows[0]["oppGoalVGame"].ToString()lastrankings
        //                //        + ")<1 and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1  and oddCompany='" + comboBoxEdit4.Text + "' and type='客队近六轮' and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";
        //                strsql1 = "  abs(goalVGame-" + dttemp.Rows[0]["goalVGame"].ToString()
        //                    + ")<1.1 and abs(oppGoalVGame-"
        //                    + dttemp.Rows[0]["oppGoalVGame"].ToString()
        //                    + ")<1.14 and abs(marginGoal-" + dttemp.Rows[0]["marginGoal"].ToString() + ")<1   and oddCompany='" + comboBoxEdit4.Text + "' and type='客队客场' and homeGoal='" + dttemp.Rows[0]["homeGoal"] + "' and vistorGoal='" + dttemp.Rows[0]["vistorGoal"] + "' ";

        //                strsql2 = "   guessNum in (select distinct guessNum from fbOddTeamResultView  where " + strsql1 + "   ) and  guessNum in (" + strgoal + ")";
        //                strsql1 = "select * from  fb_gamelist where   " + strsql2 + "   ";
        //                ds = ar.ReturnDataSet(strsql1);
        //                dttemp = ds.Tables[0];
        //                if (dttemp.Rows.Count == 0) continue;

        //                strgoal = "";
        //                foreach (DataRow dr in dttemp.Rows)
        //                {
        //                    homeTeamName = dr["homeTeamName"].ToString().Substring(dr["homeTeamName"].ToString().IndexOf("(") + 1, dr["homeTeamName"].ToString().IndexOf(")") - dr["homeTeamName"].ToString().IndexOf("(") - 1).Replace(" ", "");
        //                    vistortTeamName = dr["vistortTeamName"].ToString().Substring(dr["vistortTeamName"].ToString().IndexOf("(") + 1, dr["vistortTeamName"].ToString().IndexOf(")") - dr["vistortTeamName"].ToString().IndexOf("(") - 1).Replace(" ", "");
        //                    time = dr["inTime"].ToString().Substring(0, dr["inTime"].ToString().LastIndexOf("-"));
        //                    if (hsteam.ContainsKey(homeTeamName + "-" + vistortTeamName + "-" + time) == false && dr["guessNum"].ToString() != comboBoxEdit3.Text && dr["GameScore"].ToString() != "" && dr["GameScore"].ToString() != "no match")
        //                    {
        //                        if (hsscore.Contains(dr["GameScore"]))
        //                        {
        //                            j = Convert.ToInt32(hsscore[dr["GameScore"]]);
        //                            j++;
        //                            hsscore[dr["GameScore"]] = j;
        //                        }
        //                        else
        //                        {
        //                            hsscore.Add(dr["GameScore"], 1);
        //                        }
        //                        hsteam.Add(homeTeamName + "-" + vistortTeamName + "-" + time, 1);
        //                        hsnum.Add(dr["guessNum"], 1);
        //                    }
        //                    Application.DoEvents();
        //                }
        //                ArrayList akeys = new ArrayList(hsscore.Keys);
        //                int index = 0;
        //                int imax = 0;
        //                int icount = 0;
        //                string strnum = "";
        //                for (index = 0; index < akeys.Count; )
        //                {
        //                    imax = 0;
        //                    for (j = 0; j < akeys.Count; j++)
        //                    {
        //                        if (strgoal.IndexOf(akeys[j].ToString()) == -1)
        //                        {
        //                            icount = Convert.ToInt32(hsscore[akeys[j]]);
        //                            if (imax < icount)
        //                            {
        //                                strnum = akeys[j].ToString();
        //                                imax = icount;
        //                            }
        //                        }

        //                    }

        //                    if (strgoal == "")
        //                    {
        //                        strgoal = strnum + "(" + imax + ")";
        //                    }
        //                    else
        //                    {
        //                        strgoal = strgoal + "," + strnum + "(" + imax + ")";

        //                    }
        //                    index++;
        //                }
        //                if (strgoal != "" && strgoal.IndexOf(",") == -1)
        //                if (strgoal != "")
        //                {
        //                    if (drall["GameScore"].ToString() != "")
        //                    {
        //                        memoEdit1.Text = drall["guessNum"].ToString() + "(" + drall["GameScore"] + ")" + ":" + strgoal + "\r\n" + "homeGoal:" + homeGoal + "\r\n" + "vistorGoal" + vistorGoal+"\r\n\r\n" + memoEdit1.Text;
        //                        if (strgoal.IndexOf(",") == -1 && strgoal != "") if (strgoal.IndexOf(drall["GameScore"].ToString()) > -1 && strgoal != "") iright++;
        //                        if (strgoal.IndexOf(",") == -1 && strgoal != "") iall++;
        //                    }
        //                    else
        //                    {
        //                        memoEdit1.Text = drall["guessNum"].ToString() + ":" + strgoal + "\r\n" + "\r\n\r\n" + memoEdit1.Text;
        //                        if (strgoal.IndexOf(",") == -1 && strgoal != "") iall++;
        //                    }

        //                    Application.DoEvents();
        //                }
        //            }
        //            memoEdit1.Text = dtdate["gameDate"].ToString() + ":" + iright + ":" + iall + "\r\n" + "\r\n\r\n" + memoEdit1.Text;
        //        }
        //    }
        //    catch { }
        //    simpleButton5.Text = "....";
        //    simpleButton5.Enabled = true;
        //}


    }
}
